Keysym to modifiers state

Glynn Clements glynn at
Wed Nov 2 09:37:28 PST 2005

Cvetelin Andreev wrote:

> XKeysymToKeycode functions returns the keycode for the keysym, it does not  
> tell you whether Shift is pressed or not.

Call XGetKeyboardMapping, and scan the resulting table for the desired
keysym. The first column is with no modifiers, the second column is
with Shift, the third with AltGr, the fourth with both. The third and
fourth columns are optional.

To determine the correct modifier for AltGr, you need to scan the
table returned by XGetModifierMapping for the Mode_switch or
ISO_Level3_Shift keysyms.

For more details, look at how "xmodmap -pk" and "xmodmap -pm" work.

Glynn Clements <glynn at>

More information about the xorg mailing list