Ubuntu – How to swap/remap the CAPS LOCK key with Tab key

keyboard

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?

Best Answer

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