Home Connect Gallery Blog

Switch Caps Lock and Escape (Linux)

Jade Thornton

The standard QWERTY keyboard is great in a lot of ways and for a lot of uses. My current keyboard has been with me for years and I know it well, but if I could change the locations of a couple keys, I would. And naturally, that's what I did.

The most useful change I've made is switching the Caps Lock and Escape keys. This is much easier (after the initial muscle-memory retraining) because of how often I use Escape while programming. Instead of a reach up to the edge of the keyboard, it's only one key to the left of my pinky finger on home row. So how do you do it? It's pleasantly simple:

First, add the folowing code to your ~/.Xmodmap (note the capital X):

            clear Lock
            keysym Caps_Lock = Escape
            keysym Escape = Caps_Lock
            add Lock = Caps_Lock

Next, add the following line to your ~/.zshrc (or ~/.profile if you're using bash):

            xmodmap ~/.Xmodmap

There you go! source ~/.zshrc (or logout and login again for bash) and they should switch!