Package: gdk

Function gdk-keymap-translate-keyboard-state

Lambda List

gdk-keymap-translate-keyboard-state (keymap keycode state group)

Arguments

keymap -- a gdk-keymap object
keycode -- an unsigned integer with the keycode
state -- a gdk-modifier-type modifier state
group -- an integer with the active keyboard group

Return Value

keyval -- an unsigned integer with the keyval
effective -- an integer with the effective group
level -- an integer with the level
consumed -- the gdk-modifier-type flags that were used to determine the group or level

Details

Translates the contents of the keycode, state, and group arguments into a keyval, effective group, and level. Modifiers that affected the translation and are thus unavailable for application use are returned in consumed. The effective return value is the group that was actually used for the translation. Some keys such as the Enter key are not affected by the active keyboard group. The level is derived from state. For convenience, the gdk-event-key event already contains the translated keyval, so this function is not as useful as you might think.

The consumed flags gives modifiers that should be masked out from state when comparing this key press to a hot key. For instance, on a US keyboard, the Plus symbol is shifted, so when comparing a key press to a <Control>Plus accelerator the Shift key should be masked out.
/* We want to ignore irrelevant modifiers like ScrollLock */
#define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK |
                         GDK_MOD1_MASK)
gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
                                     event->state, event->group,
                                     &keyval, NULL, NULL, &consumed);
if (keyval == GDK_PLUS &&
    (event->state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
  /* Control was pressed */  
 

See also

2021-12-13