17

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?

wyc
  • 1,711

3 Answers3

13

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
Panther
  • 102,067
  • Thanks a lot. Just one question: what did you mean by 'temporarily set your keymap? ' Running these lines in the terminal? – wyc Jan 11 '12 at 05:56
  • yes, you can test the settings out in a terminal by running those commands. – Panther Jan 11 '12 at 05:58
  • 2
    Hey it worked but the Caps Lock still turning on and off. What can be causing this? – wyc Jan 11 '12 at 08:15
  • 1
    You may need to clear your setting first in ~/.Xmodmap (I did not need to do this). See https://wiki.archlinux.org/index.php/Xmodmap and http://manpages.ubuntu.com/manpages/precise/man1/xmodmap.1.html – Panther Jan 11 '12 at 16:08
  • 1
    alt-capslock doesn't work like alt-tab when you do this. – pwned May 26 '13 at 04:33
10

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
Charaf
  • 101
  • 1
  • 2
-1

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

Simon
  • 4,813
  • 8
  • 35
  • 52
thomas
  • 1