Although there are lots of different articles how to change the left Alt to simulate win , I want to map the right Alt to do so. I want to move to 11.10, I fall back to unity 2d and dont have a win key. I kennot even get the keycode in the articles I found... Any help or good suggestions?

2 Answers 2


You can use xmodmap to remap any key on the keyboard; in particular, you can remap the right Alt to act as a Super/Win key.

Create a file named .Xmodmap in your home directory with the following content:

! free up right-Alt for remapping
remove mod1 = Alt_R

! Right-Alt remapped to Super
clear mod4
keycode 108 = Super_R
add mod4 = Super_R

When you log out and then log in again, GNOME should ask you if you want to load the .Xmodmap file; answer "yes" and you're ready to go. (You will only asked once.)

Alternatively, you can load the .Xmodmap configuration from a terminal at any time:

xmodmap .Xmodmap

There are a few things that can vary depending on the X server version and keyboard model. The following items could help you adapt the .Xmodmap file to your specific environment.

  1. Check that your right Alt key is initially on mod1: Issue the command xmodmap in a terminal window, and you should get an output like this one:

    xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):
    shift       Shift_L (0x32),  Shift_R (0x3e)
    lock        Caps_Lock (0x9),  Caps_Lock (0x4e)
    control     Control_L (0x25),  Control_R (0x69)
    mod1        Alt_L (0x40),  Alt_R (0x6c),  Alt_L (0xcc)
    mod3        Mode_switch (0xcb)
    mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce)

    If the Alt_R tag does not appear in the mod1 line but on a different one, adjust your .Xmodmap accordingly.

  2. Check that your right Alt key is keycode 108: in a terminal window, type the command xev, then focus the small square window that popped up. If you type the right Alt key there, you should see lines appearing in the terminal window. Look for a stanza like this one:

    KeyPress event, serial 25, synthetic NO, window 0x5000001,
        root 0xbd, subw 0x5000002, time 867397196, (53,48), root:(54,49),
        state 0x0, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
        XLookupString gives 0 bytes: 
        XmbLookupString gives 0 bytes: 
        XFilterEvent returns: False

    The number after the keycode word is the one you want in your .Xmodmap file for remapping right Alt.

  • Thank you. I can keep my left all for all the things I need.
    – deckoff
    Oct 23, 2011 at 18:44
  • strange, although the solution used to work, now it stopped??? When I restart the PC and recreate the solution, it works until the next restart...
    – deckoff
    Oct 25, 2011 at 19:04
  • 1
    @deckoff It means that your .Xmodmap file is not being read at the start of the X session. Try adding xmodmap ~/.Xmodmap to your .gnomerc (or equivalent) file. Oct 25, 2011 at 19:21
  • 1
    Yes, adding xmodmap ~/.Xmodmap to .gnomerc worked
    – deckoff
    Oct 26, 2011 at 20:46
  • 1
    The mapping only worked properly for me when I set keycode 108 = Super_R Super_R Super_R Super_R (4 times, to account for the modified options) Apr 28, 2021 at 16:50

I found that simply:

remove mod1 = Alt_R
add mod4 = Alt_R

works as hoped. Am I missing any "gotchas" with this method?


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.