Using Alt Gr to switch windows in Ubuntu

Now that I’m on the move for a couple of months, I’m using a Dell Inspiron Mini to do all my work. As soon as I switched away from my Macbook I missed using the right-hand ⌘ with Tab to change windows. I’ve found that using opposite hands when modifying keys can relieve some repetitive strain.

However, Ubuntu’s default for the Alt Gr key is to create accented characters. This is entirely understandable, as that is what the Alt Gr key is used for. However, I rarely need these characters and would much rather save myself some hand strain.

Luckily, it’s easy, after the obligatory two-hour Google search, and some excessive use of ‘xev’:

xmodmap -e 'keycode 108 = Alt_R'

Once this is done you can use both left Alt and Alt Gr to switch windows. Hurray!

Note that you might need a different keycode for your setup, so use xev from the Terminal to find the keycode for your own Alt Gr.

To make this more permanent, stick ‘keycode 108 = Alt_R’ into ~/.xmodmap and Ubuntu will ask if you want to use it on your next boot.

One Reply to “Using Alt Gr to switch windows in Ubuntu”

  1. If you have more than one layout set, define it in the following way:

    xmodmap -e ‘keycode 108 = Alt_R Alt_R Alt_R’

    To make the right alt work on your secondary layout as well.

    Another very useful command that might help you:
    xmodmap -pke

    It prints the full list of keycodes definitions.

Comments are closed.