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?

3 Answers 3


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
  • Thanks a lot. Just one question: what did you mean by 'temporarily set your keymap? ' Running these lines in the terminal?
    – wyc
    Jan 11, 2012 at 5:56
  • yes, you can test the settings out in a terminal by running those commands.
    – Panther
    Jan 11, 2012 at 5:58
  • 2
    Hey it worked but the Caps Lock still turning on and off. What can be causing this?
    – wyc
    Jan 11, 2012 at 8:15
  • 1
    You may need to clear your setting first in ~/.Xmodmap (I did not need to do this). See wiki.archlinux.org/index.php/Xmodmap and manpages.ubuntu.com/manpages/precise/man1/xmodmap.1.html
    – Panther
    Jan 11, 2012 at 16:08
  • 1
    alt-capslock doesn't work like alt-tab when you do this.
    – pwned
    May 26, 2013 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
  • 1
    Could you expand on your answer?
    – Virusboy
    Jan 22, 2015 at 21:58
  • How is it different from the accepted answer?
    – Seth
    Jan 23, 2015 at 17:22
  • 1
    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, 2015 at 20:10
  • 2
    @Seth The important difference is the clear Lock which clears the old behaviour. Apr 13, 2015 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.

  • You sure? It says Alt Right and Alt Left there.
    – Braiam
    Sep 13, 2013 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .