Switch Capslock to work as Escape on Linux

Let’s be honest, how often do you ever use caps lock? Hardly ever. Personally, I can count on one hand the number of times I’ve ever really found caps lock to be worth the trouble. Yet its right there, millimeters away from the “A” key. Such prime real estate going to waste.

Conversely, how often do you use Escape? I use it all the time. Yet its way the hell up there on the keyboard. You have to remove your fingers from the home row, and go hit the Escape button, and reorient your hand every time you want to hit Escape.

In the name of efficiency (and the little finger on my left hand) I deactivate caps lock all together and force the caps lock key to work as the “Escape” key. Its one keyboard hack I can’t really live without, especially as a vim user. You can make the switch easily on linux. Just run
xmodmap -e 'clear Lock' #ensures you're not stuck in CAPS on mode
xmodmap -e 'keycode 0x42=Escape' #remaps the keyboard

With this hack, your caps lock key will work as an escape key, and your hands just became a little less prone to carpal tunnel syndrome.

This entry was posted in Open Source, Ubuntu. Bookmark the permalink.

4 Responses to Switch Capslock to work as Escape on Linux

  1. Mackenzie says:

    I’ve been doing this for a long time. You get 2 Esc keys this way. If you still want access to a Caps key though, you can set that in a GUI. I know it’s in GNOME’s Keyboard Preferences, though I don’t know the headings to find it. In KDE:
    – System Settings
    – Region & Language
    – Keyboard Layout
    – Advanced
    – CapsLock Key Behaviour
    – Swap ESC and CapsLock

  2. Pingback: GVIM customizations in Linux « eindoofus

  3. Alex Ozer says:

    To map Caps Lock to Escape, just use:
    $ xmodmap -e ‘keycode 0x09=Caps_Lock’

Leave a Reply

Your email address will not be published. Required fields are marked *