How To Turn Your Caps-Lock Key Into Escape In Linux

Ever since I started learning Vim, I’ve been using escape more than ever. With Vim, you are constantly hitting escape when switching between modes and that means you have to stretch over to the escape key. Although it isn’t a lot of work, when you are constantly doing it for hours on end, it can get quite annoying. Furthermore, when was the last time someone used the Caps-Lock key other than shouting over the internet?

In this article, you will turn your Caps-Lock key into an additional escape key. This should work on all distributions, desktop environments and window managers. Unfortunately, I haven’t tested it under Wayland so it might not work there.


  1. Open up a terminal and run the following command: sudo vim /etc/default/keyboard
    1. You can replace vim with whatever text-editor you desire (eg: nano, gedit, sublime-text, emacs)
  2. Add the following or change the values accordingly: XKBOPTIONS="caps:escape"
  3. Save and quit then run the following command: sudo dpkg-reconfigure keyboard-configuration It will ask you to select your keyboard, locale and preferred layout. (QWERTY, Colemak, Dvorak, Workman etc.) Simple complete the setup and wait for it to finish updating initramfs.
  4. The changes should take effect immediately after finishing step 3. If it is still registering as a caps-lock key, then give it a reboot.

Emacs Users

If you’re an Emacs user, you can change the value for XKBOPTIONS to XKBOPTIONS="caps:control" or XKBOPTIONS="control:nocaps" and run step 3 again. This will map your Caps-Lock key to another control key. After all, if you’re going to spend time in a “control-key-simulator”, you might as well make it comfortable :^)


Leave a comment

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

Blue Captcha Image


One thought on “How To Turn Your Caps-Lock Key Into Escape In Linux”

  • Avatar