I use a us-intl with "AltGr dead keys" layout and the option to switch Alt and Win key. Nice, but my AltGr does not work. The key I want to use for AltGr has keycode 134 (found out using xev). So I create a .Xmodmap file:

keycode 134 = ISO_Level3_Shift Multi_key ISO_Level3_Shift Multi_key

than I execute "xmodmap .Xmodmap". When I now show my modifier, I get:

> xmodmap
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x85),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod4        Super_L (0x40),  Super_R (0x6c),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  ISO_Level3_Shift (0x86),  Mode_switch (0xcb)

But ... pressing AltGr (the key with code 134=0x86) + q does not give the expected result - which would be "a-umlaut". It should! xmodmap -pke contains this line:

keycode  24 = q Q q Q adiaeresis Adiaeresis adiaeresi

So what is wrong and what can I do?


According to the Xmodmap Manual, when you want to swap or change modifier keys you need to remove & clear their ties to their original keycodes and modifier groups. Then after assigning them to a new keycode you must also assign them to a new, unique group.

It looks like the problem is that you've assigned two different modifiers to the same key: [ISO_Level3_shift] & [Mode_switch]. And you've also assigned them to the same modifier group. The effect of assigning them to the same group is that: pressing one of them, activates/sends them both to the system.

[ISO_Level3_shift] & [Mode_switch] are not synonymous. Each of these keys is meant to provide access to a unique layer/level of the keyboard. And when pressed together they can access even higher levels if your keyboard supports them.

Another potential complication is that on virtually all systems Xmodmap is running on top of xkb (which defines certain aspects of the underlying virtual keyboard).

[Mode_switch] is synonymous with [AltGr] to Xmodmap providing access to level 2- that would be the second set of [q] & [Q] in your example. Whereas [ISO_Level3_shift] provides access to level three- the [ä] & [Ä] in your example.

But since both keys share the same modifier group in your example they are both being pressed which is probably trying to access your highest level; but since there seems to be an error* you are probably either not getting any output, or some unexpected output coming from the underlying xkb.

Basically you can fix this by changing your .xmodmap file. Just assign [Level3_shift] & [Mode_switch] to separate keys and separate modifier groups. Or, actually I would just recommend that you just remove the reference to Mode_switch altogether. I have found it to behave rather oddly; the 3rd level shift key seems to behave more consistently and reliably.

*-your second "adiaeresi" (sic.) is missing the final [s] so it wouldn't produce any character.

I know this rather confusing and convoluted for no apparent reason, plus this thread is old. But hopefully someone will find my explanation useful at some point!

| improve this answer | |
  • I am wondering if xmodmap is the best way to do it in general nowadays? – Thomas Dec 24 '19 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.