4

Image of keyboard

EDIT: This is Ubuntu 23.04 x64 in the default Ubuntu flavor.

I have upgraded my ancient Model M keyboard to a modern one where Windows keys have been added. Being Danish we use the Alt-Gr key a lot which has been shifted one key to the right and a Windows key is now where my muscle memory goes.

I would like to remap the right Windows key to Alt-Gr (and leave the left Windows key as is. The output from xev when pressing and releasing the keys is:

KeyPress event, serial 38, synthetic NO, window 0x3800001,
    root 0x49d, subw 0x0, time 18696093, (125,74), root:(2722,175),
    state 0x10, keycode 134 (keysym 0xffec, Super_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 38, synthetic NO, window 0x3800001,
    root 0x49d, subw 0x0, time 18696725, (125,74), root:(2722,175),
    state 0x50, keycode 134 (keysym 0xffec, Super_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 38, synthetic NO, window 0x3800001,
    root 0x49d, subw 0x0, time 18697421, (125,74), root:(2722,175),
    state 0x10, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 38, synthetic NO, window 0x3800001,
    root 0x49d, subw 0x0, time 18698721, (125,74), root:(2722,175),
    state 0x90, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

What is the best way to do this remapping? Can the Ubuntu tools help edo this, or do I need to do some low level X11 magic?

1 Answers1

5

That's what the Alternate Characters Key control in Settings -> Keyboard is for.

Disable the Use layout default switch and select Right Super.

Gunnar Hjalmarsson
  • 32,938
  • 3
  • 63
  • 94
  • This made my right Windows key get the Alt-GR functionality (but the Alt-Gr key lost it). This is not very well explained in the Settings program, so thanks for pointing it out. – user18619318 Jul 03 '23 at 09:57
  • @user18619318: Any idea how it could be explained better? – Gunnar Hjalmarsson Jul 03 '23 at 11:20
  • Explicitly mentioning that this is the Alt-Gr behavior would have been helpful. – user18619318 Jul 04 '23 at 08:10
  • @user18619318: Note that the key is named "Right Alt" on some keyboards While the / key is used by default as the key for accessing 3rd and 4th level symbols, "the AltGr behavior" wouldn't describe the control very accurately. – Gunnar Hjalmarsson Jul 04 '23 at 14:21
  • I would suggest that mentioning in passing the information you just stated there, would help others like me to actually understand what the help text is helping with. – user18619318 Jul 04 '23 at 15:32
  • @user18619318: Currently it says: "The alternate characters key can be used to enter additional characters. These are sometimes printed as a third-option on your keyboard." Would you like to see an elaboration of that info? – Gunnar Hjalmarsson Jul 04 '23 at 17:21
  • Yes. "third-option" only makes sense if you know what it is already. "These are sometimes printed as a third-option on your keyboard, frequently Alt-Gr." would probably be sufficient. – user18619318 Jul 05 '23 at 08:05
  • @user18619318: I see the point, and I'll make a mental note about it for now. It's a bit complex, because that section is from GNOME, but Ubuntu applies a couple of patches which need to be taken into consideration. – Gunnar Hjalmarsson Jul 05 '23 at 10:35