10

We have ergonomic keyboards at work which I'm not entirely used to. I seem to keep hitting the capslock key while I'm in vim and it's starting to annoy. How can I disable this key, and or change to to be another key?

xenoterracide
  • 59,188
  • 74
  • 187
  • 252

4 Answers4

7

The quick and dirty way to disable it is with xmodmap:

$ xmodmap -e 'clear Lock'

The next question is what would you like to do with it? I usually make it either a Ctrl key:

$ xmodmap -e 'keycode 66 = Control_L'

Depending on your DE/WM, there is likely a way to do this in the GUI configuration. For example Gnome has a "keyboard layout" option on the control pannels with an options tab that includes several similar layout modifications.

Caleb
  • 70,105
6

Use xmodmap.

The setting to disable your capslock is

remove Lock = Caps_Lock

This would be placed in your .xmodmap file.

Another option - to disable it temporarily, you can use a setxkbmap option:

setxkbmap -option ctrl:nocaps

and then, to restore normal behavior: setxkbmap -option

3

Using xmodmap will only change the key binding while in X. If you need it on the console it's a little different. The changes below will modify X as well as the console, so I always do it this way.

For Linux add this to /etc/rc.local (or make an init script):

(echo $(dumpkeys |grep -i keymaps); echo keycode 58 = Control) | loadkeys -

For Solaris on a PC with a USB keyboard edit /usr/share/lib/keytables/type_6/reset (for other types of keyboards you would replace type_6 with the appropriate type):

Locate this line:

key 57   all shiftkeys+capslock

Replace with this:

key 57   all shiftkeys+leftctrl up shiftkeys+leftctrl

Naturally you can replace Control with any key you would like.

bahamat
  • 39,666
  • 4
  • 75
  • 104
0

This is a portion of my .xmodmaprc, that turns CapsLock into Esc, and vice versa:

clear lock

keycode 9 = Caps_Lock ISO_Next_Group Caps_Lock ISO_Next_Group
keycode 66 = Escape NoSymbol Escape

add lock = Caps_Lock

You can check the keycodes by running xev and just pressing the buttons you want to check.

polemon
  • 11,431