Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been trying to swap CAPS LOCK key with Tab key. So the CAPS LOCK key shouldn't turn on the CAPS anymore, instead, act as the Tab key. Some people told me that I should create a .Xmodmap file in the ~/ directory. But I have no idea what's next.

Any suggestions?

share|improve this question
up vote 9 down vote accepted

First list your current settings with

xmodmap -pke|egrep  -e '(Tab|Caps)'

I get this output

keycode  23 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode  66 = Caps_Lock NoSymbol Caps_Lock

So, temporarily set your keymap

xmodmap -e "keycode  66 = Tab ISO_Left_Tab Tab ISO_Left_Tab"
xmodmap -e "keycode  23 = Caps_Lock NoSymbol Caps_Lock"

Assuming that works, add those lines to ~/.Xmodmap

keycode  66 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode  23 = Caps_Lock NoSymbol Caps_Lock

You can then either log out and back in or

xmodmap ~/.Xmodmap
share|improve this answer
Thanks a lot. Just one question: what did you mean by 'temporarily set your keymap? ' Running these lines in the terminal? – janoChen Jan 11 '12 at 5:56
yes, you can test the settings out in a terminal by running those commands. – bodhi.zazen Jan 11 '12 at 5:58
Hey it worked but the Caps Lock still turning on and off. What can be causing this? – janoChen Jan 11 '12 at 8:15
You may need to clear your setting first in ~/.Xmodmap (I did not need to do this). See and – bodhi.zazen Jan 11 '12 at 16:08
alt-capslock doesn't work like alt-tab when you do this. – pwned May 26 '13 at 4:33

what works for me is this code:

clear Lock
keycode  66 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode  23 = Caps_Lock NoSymbol Caps_Lock
share|improve this answer
Could you expand on your answer? – Virusboy Jan 22 '15 at 21:58
How is it different from the accepted answer? – Seth Jan 23 '15 at 17:22
alt-capslock is now working like alt-tab (as motioned by @pwned ). And clicking Caps Lock key doesn't turn on and off (as motioned by janoChen ). – Charaf Jan 23 '15 at 20:10
@Seth The important difference is the clear Lock which clears the old behaviour. – Jan Vlcinsky Apr 13 '15 at 15:14

For alt-capslock: in your .Xmodmap file, add clear Mod1 at the beginning and add Mod1 = Alt_L Alt_R at the end.

share|improve this answer
You sure? It says Alt Right and Alt Left there. – Braiam Sep 13 '13 at 11:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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