Archie Maskill
A software development blog

Remapping Caps Lock

This week, I bit the bullet and ripped the Caps Lock key out of my keyboard. Not content with that, I ripped out the left Ctrl key too, and stuck it back in where the Caps Lock had been. I didn’t put the Caps Lock back in – I left it on a spike next to my monitor, as a warning against all crap interface design decisions.


To make the keyboard usable again, I tried the following registry modification: create a file called swapCapCtrl.reg and copy-paste the following lines of text into it:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00

Double-clicking this file and rebooting the computer will swap the Caps Lock and Left Control keys around. To undo this, just fire up regedit.exe and remove the entry that was placed in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout and then reboot.

This all works, but you need to go through this rigmarole every time someone who can’t handle this keyboard modification wants to use your computer.

To solve this, download and install AutoHotKey, create a file called swapCapsCtrl.ahk and place the following code in it:


Double-click the file to set the script running in the background, and right-click->Exit its System Tray icon to remove it. This is my preferred method because: I already have and use AutoHotKey; the behaviour is readily toggled; Caps Lock is moved to the Right Ctrl key, where I’m even less likely to hit it accidentally (although, I still find that I do, so I’ve removed that second line entirely).


Add the following text to your ~/.xmodmap file, then restart your desktop session:

remove Lock = Caps_Lock
keysym Caps_Lock = Control_L
add Control = Control_L

This deals with the X server side of things, but you must do something else to get this effect in a virtual terminal (i.e. when you press Ctrl-Alt-F1, etc.). Edit the file /etc/console-tools/remap, such that it contains the following line: s/keycode 58 = Caps_Lock/keycode 58 = Control/;

If none of the above works for you, for whatever reason, I refer you to Moving The Ctrl Key, over on the Emacs Wiki.

With this keyboard tweak, I did have something of an uncertain start, but it nows feels to have been worth it. Ctrl-Tabbing and Ctrl-Shift-Tabbing between Firefox tabs seems more natural, and I now look at Ctrl-T on my laptop’s unmodifed keyboard and think did I really used to go to all that effort just to open a new tab?.


No Responses to “Remapping Caps Lock”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: