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
-
Start fresh by deleting
~/.Xmodmap
. -
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
On Ubuntu 19.04, To make the mapping system-wide, you should change two files:
- /usr/share/X11/xkb/symbols/altwin
- /usr/share/X11/xkb/symbols/pc
Add the following section to the former one:
// Ctrl is mapped to the Alt.
partial modifier_keys
xkb_symbols "right_alt" {
key <LALT> { [ Alt_L, Meta_L ] };
key <RALT> { type[Group1] = "TWO_LEVEL",
symbols[Group1] = [ Control_R, Control_R ] };
modifier_map Mod1 { Alt_L, Alt_R, Meta_L, Meta_R };
modifier_map Control { <LCTL>, <RALT> };
};
And substitute include "altwin(meta_alt)"
to the include "altwin(right_alt)"
in the latter.