14

I have an annoying UK keyboard which has an Alt Gr key where the right Alt key is on a US keyboard. This is really annoying when using Gnome which makes heavy use of the Alt/Meta key.

Does anyone know how I can map the Alt Gr key to the Alt key?

Jawa
  • 3,679

5 Answers5

12

gnome-tweak-tool lets you do this with a GUI:

Typing -> Key to choose 3rd level -> Right Alt key never chooses 3rd level

8

For those UK users still pulling their hairs out, this worked for me:

xmodmap -e "clear mod5"
xmodmap -e "keycode 108 = Alt_L"

Explanation: The first line removes the current behaviour of your AltGr (which is assigned to the mod5 modifier). The second takes the AltGr key (which on my keyboard produces a keycode of 108), and maps that to whatever keycode your Alt_L key is mapped to.

If you have no idea what is going on with keycodes and keysyms, I found this xmodmap introduction very useful.

cammil
  • 252
  • 2
  • 8
1

====Change AltGr to Alt in Gnome

Click on Show Applications > Settings > Keyboard > In Special Character Entry click on Alternate Characters Key > Put Use layout default to Off > Click on None.

In Special Character Entry also click on Compose Key > Put Use layout default to Off > Click on Left Alt > Put Use layout default to On.

To test if it works correctly start the Terminal. Write a short text, for example “Write a short text.” Press Right Alt and B at the same time. If the the cursor goes back a word it works as it should.

1

xmodmap

The 'shift, lock, control, modN' on the left are what X sees and cares about. The keysyms on the right map to them. Mode_switch is your AltGr key. Move it to join the others at mod1:

xmodmap -e 'clear mod5'
xmodmap -e 'add mod1 = Mode_switch'
ayrnieu
  • 287
0

If the above answers still do not work you then run xev -event keyboard (you may need to install it first) and press AltGr with the Event Tester window in focus. You should see something like the following in the shell.

KeyPress event, serial 163, synthetic NO, window 0x1600001,
    root 0x119, subw 0x0, time 21667560, (151,737), root:(1111,764),
    state 0x10, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

On the third line it gives you the keycode and keysym name, which in my case is ISO_Level3_Shift. Now run xmodmap and check the output before doing

xmodmap -e "remove mod5 = ISO_Level3_Shift"
xmodmap -e "add mod1 = ISO_Level3_Shift"

where ISO_Level3_Shift should be replaced with the correct key symbol if necessary. Finally you need to add this to your user rc script to make it persistent.

DavidPostill
  • 162,382