How to set right Alt to work as a Win(Super) key?
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?
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.
-
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) mod2 mod3 Mode_switch (0xcb) mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce) mod5
If the
Alt_R
tag does not appear in the mod1 line but on a different one, adjust your.Xmodmap
accordingly. -
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.
I found that simply:
remove mod1 = Alt_R
add mod4 = Alt_R
works as hoped. Am I missing any "gotchas" with this method?