as many others I don't need CapsLock. I want to reassign it such that it has the function of AltGr. I use Kubuntu 9.10 but I think there must be a solution which is distribution independent.

I already tried to use setxkbmap or xmodmap. Using xmodmap at least I managed that CapsLock to behaves like Del by following this description.

But I could not achieve assigning the AltGr behavior to CapsLock.


I know this question is old, but if anyone stumbles across it again, there is an alternative solution:

setxkbmap -option "lv3:caps_switch"

For a full list of options, read the "OPTIONS" section of

man xkeyboard-config
| improve this answer | |

Based on Dennis' answer and by playing around with xev I found out that the magic phrase seems to be ISO_Level3_Shift.

At least this works for me:

xmodmap -e "keycode 66 = ISO_Level3_Shift"

Now I dont' run into danger to break my fingers while typing [, ], {, } and co on my german keyboard layout.

Edit: now using the -e option of xmodmap

| improve this answer | |
  • Thanks! I've been looking for exactly this since moving to Ubuntu from Windows. Without this JavaScript is a pain on a German keyboard. – gzost Feb 12 '16 at 14:17

Long's answer is the best one for modern Desktops like Gnome, because Gnome itself uses xkb and overwrites xmodmap configurations by default (also, xmodmap is on its way out and unsupported in Wayland). Unfortunately, it will still only work until reboot.

You can apply this option permanently for your Gnome desktop with this command:

gsettings set org.gnome.desktop.input-sources xkb-options "['lv3:caps_switch']"

Of course you can also make this change permanently and even system wide, without using Gnome. If you use Gnome, you should still use the above command to keep Gnome from overwriting this setting. For Arch, you can add a file /etc/X11/xorg.conf.d/90-custom-kbd.conf with the following content:

Section "InputClass"
    Identifier "keyboard defaults"
    MatchIsKeyboard "on"
    Option "XKbOptions" "lv3:caps_switch"

I assume this differs between distributions, so your mileage might vary.

| improve this answer | |

Try one of these (substitute the keysim or keycode of your caps-lock key if it's different):

xmodmap -e "keysym 0xffe5 = Mode_switch"


xmodmap -e "keycode 66 = Mode_switch"
| improve this answer | |
  • Thanks. Your line did not work directly for two reasons: 1. xmodmap wants a file so I have to pipe the string and read from stdin. 2. Mode_switch was successfully assigned but did not result in the 3rd level modifier. Then I played with xev again. When I realized that the string "Mode_switch" showes up there it was easy to press AltGr and look what one could read instead in the corresponding place. -> ISO_Level3_Shift. – cknoll May 7 '10 at 14:38
  • @basweber: I forgot the -e option. I've edited my answer. – Paused until further notice. May 7 '10 at 15:13
  • Yes. Thats much cleaner than the piping approach. – cknoll May 8 '10 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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