Search code examples
cinputxlib

How do I handle non US keyboard layouts with Xlib and xkb?


I'm using a Swedish keyboard layout and can't get access to many keys such as the bracket keys since I have to press AltGr to get access to them. I'm using the XkbKeycodeToKeysym to translate keycodes to keysyms but I only get 0 as a keysym when pressing AltGr.

AltGr is Mod5Mask according to the X.h file. The state is 128 when pressing it.

I've tried to pass different levels and groups to XkbKeycodeToKeysym with no results.


Solution

  • The function I needed was Xutf8LookupString and using that. I followed this tutorial for when configuring the input context.