Ubuntu – remap right alt to behave as right ctrl

xmodmap

I'm trying to remap my right alt to behave like my right ctrl so I can use my right thumb to press the ctrl button. This is Ubuntu 12.04.

I've created the file .Xmodmap in my home folder with the following content:

clear control
clear mod1
!keycode 64 = Alt_L Meta_L
keycode 108 = Alt_R Meta_R
add control = Control_L Control_R Alt_R
add mod1 = Alt_L Meta_L

As you might guess, my left alt key has keycode 64 and my left alt key has keycode 108.

This actually works in the sense that my right alt key behaves as if I press the ctrl key.

However my left alt key now doesn't do anything anymore, which means I don't have an alt key left. This is strange given that xmodmap gives the following output:

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

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

The strange thing is that when I remove the Alt_R mapping onto control, the alt keys work.

(ie., change the second to last line to:)

add control = Control_L Control_R

Now even my right alt behaves as an alt key which confuses me. After removing the Alt_R mapping from the control line the output of xmodmap gives:

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

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

Hope you guys can help.

ps. I used this website as a source.

Best Answer

You should be able to simply use Keyboard Layout >> Options >> Ctrl key position >> Right Alt as Right Ctrl, but this doesn't work. This has already been filed against Debian as Bug#663218

  1. Start fresh by deleting ~/.Xmodmap.

  2. Note that you do not need to clear Control and Mod1. This makes it easier to change only what you want. Your ~/.Xmodmap shoud be:

    !Swap right control and right alt
    remove Control = Control_R
    remove Mod1 = Alt_R
    keycode 105 = Alt_R
    keycode 108 = Control_R
    add Control = Control_R
    add Mod1 = Alt_R
    
Related Question