How to get the value of the key pressed in GTK (which key the user pressed) and then display it on the screen?

As I understand it, this "should" iron as follows:

mine() { создаем окно; создаем label "текст"; g\_signal\_connect(главное окно,"key_press_event", G_CALLBACK (set_text), NULL); } set\_text(GtkWidget \*widget, GdkEventKey \*event, gpointer user\_data) { перерисовка label с текстом (нажата клавиша "некая клавиша допустим А"); gchar i = event->keyval; gtk\_label\_set\_text (GTK\_LABEL (label),&i); __чтобы в переменную "i" помещалась буква которую я нажал__ g\_printf("button-press-event, %i \n", i); } 

1 answer 1

translation of the answer (original in the form of comments):

Look at the examples:

http://developer.gnome.org/gtk-tutorial/2.90/

in particular this:

http://developer.gnome.org/gtk-tutorial/2.90/x344.html

the second link is the keyboard callback code, which is similar to what you want.