CapsLock Remap Howto

Revision as of 12:29, 19 October 2006 by Root (Talk | contribs) (remap the console keyboard)

Jump to: navigation, search

CapsLock is Satan

On most PC keyboards the Caps Lock key is where the Ctrl key should be. Whenever I get a new keyboard or laptop, I always pop off the key then take a razor blade and scrape off the "Caps Lock" print. I then tweak my operating system so that it thinks this key is a Ctrl key. Some people like to make it another Esc key.

There are three remaps that you have to worry about:

1. MS Windows
2. Linux Console
3. UNIX X11


Go here Sysinternals.


You just need to remap keycode 58 from "Caps_Lock" to "Control" in your keymap file, then load the keymap using loadkeys.

The keymap files are stored in different places depending on your version of Linux. Just do a locate for "defkeymap". The keyboard maps in Ubuntu are stored here:


On Red Hat Enterprise 4 this file is stored here:


The following script takes care of this for Ubuntu Linux:

echo "transmogrify the Caps_Lock key into another Control key"
gunzip /usr/share/keymaps/i386/qwerty/defkeymap.kmap.gz
sed -i -e "s/Caps_Lock/Control/" /usr/share/keymaps/i386/qwerty/defkeymap.kmap
gzip /usr/share/keymaps/i386/qwerty/defkeymap.kmap
loadkeys -d


This can also be done through console-tools. Edit '/etc/console-tools/remap' and uncomment 'keycode 58'.

remap the X11 keyboard

When running XWindows you need to modify the X11 key map using xmodmap. It is not sufficient to just modify the console keyboard mapping. Use xmodmap to load the following keymap file (save in ~/.Xmodmap):

remove Lock = Caps_Lock
keycode 0x42 = Control_L
add Control = Control_L

make these changes persistent

These keyboard settings are not persistent after a reboot. Most Linuxes will load your ~/.Xmodmap file when you login with xdm or gdm. Some don't. If not then you should add this line to your ~/.xsession and ~/.xinitrc files (after the shebang #!/bin/sh line):

   [ -f ~/.Xmodmap ] && xmodmap ~/.Xmodmap