Mapping Caps Lock to Escape in Debian

2014-08-29 | Martin Hoppenheit | 2 min read

When was the last time you used the Caps Lock key on your keyboard? Unless you like being rude on the internet or write all SQL statements in uppercase, it’s probably been a while. That’s a pity because the key itself is located very conveniently right next to the home row. (This is where your hands are centered when touch typing: ‘asdfjkl;’ on US keyboards.) Only its function is rather useless.

So why not map it to some other key? For Vim users, Escape is a reasonable choice: They keep hitting the Escape key all the time to switch from insert mode to normal mode, but the Escape key is as far away from the home row as it can possibly get. That means a lot of unnecessary movement you could save by mapping Caps Lock to Escape. If you don’t use Vim this might sound like I am exaggerating, but trust me, this is very annoying. The Vim Tips Wiki is full of advice on avoiding the Escape key and remapping it to other keys on Windows or Unix.

There are several ways to make the Caps Lock key behave like an additional Escape key in Debian. The most elegant seem to be the following two methods.

If all users on your system agree that Caps Lock is useless and should be mapped to Escape, you can set this system wide with the following line in /etc/default/keyboard:


If you are the only one who dislikes Caps Lock not being Escape and want to change this only for yourself, you can put this in your ~/.xsessionrc:

setxkbmap -option caps:escape

The Debian keyboard configuration is described here. For some other options see Gilles Leblanc’s blog and this superuser thread.