I dual-boot elementary OS on my MacBook and it annoys me that the two alt keys do different things, but in particular that all characters for which I use the left alt key in OSX now require the right one (e.g. \ or @) which make for some very taxing finger exercise especially on the command line. So my question is, can I interchange the roles of the two alt keys?

1 Answer 1


You can use xmodmap for that. First find out the keycode(s) of the alt keys using "xev". If not installed, you should install the x11-utils package. So type

$ xev | grep keycode

in terminal, focus to the small window by clicking on it and look to the output in terminal.

Now press the ALT key(s). You will see the keycode of the key and its name (e.g. keycode 64 and ALT_L for the left ALT key). Remember the displayed code and name. Let's assume that ALT-L has code 64 and ALT-R code 77. Now type in terminal:

$ xmodmap -e "keycode 77 = Alt_L"
$ xmodmap -e "keycode 64 = ALT_R"

Note: I don't know the "real name" for right Alt key, so the name in second command will probably not be correct.

Now the behaviour of the keys should be changed. Try it. This will only work until next reboot. If you want to make it permanently, you can add the two last commands to your ~/.bashrc.

Maybe it is not the simplest way, but it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.