remap right alt to behave as right ctrl

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
    

If you are one of the unfortunate people like me that could not get xmodmap to switch right Alt with right Ctrl, then maybe this will help.

If you press right Alt and e and you get é then this solution is for you (needs improvement).

Run this in the terminal (check your keycodes with xev):

xmodmap -e "keycode 108 = Alt_R Meta_R Alt_R Meta_R"

then put this code in your .Xmodmap:

remove Control = Control_R
remove Mod1 = Alt_R
keycode 105 = Alt_R
keycode 108 = Control_R
add Control = Control_R
add Mod1 = Alt_R

This code sets your Alt_Gr key to Alt_R, and then it swaps Alt_r with Ctrl_R.

If you want this to remain after you logout, put the following commands in any of your startup shell files, for example ~/.profile:

if [ -f $HOME/.Xmodmap ]; then
  xmodmap -e "keycode 108 = Alt_R Meta_R Alt_R Meta_R"
  /usr/bin/xmodmap $HOME/.Xmodmap
fi

sources: question1 question2

Tags:

Xmodmap