Permanently Swap Escape and Capslock Key on Linux
Created: 2023-05-01 Last Modified: 2025-01-29
I am used to VIM keybindings, and it is very comfortable to have the escape key reachable. The original place for the escape key on the top left of the keyboard is very inconvenient. This can be fixed in many different ways. On Linux for example on the shell via setxbmap
or xmodmap
. I solved it via X11
. Here is how.
$ cat /etc/X11/xorg.conf.d/10-swapescape.conf
Section "InputClass"
Identifier "Swap CapsLock and Escape"
MatchIsKeyboard "on"
Option "XkbOptions" "caps:swapescape"
EndSection
This way if you are starting your Desktop Environment (XFCE/KDE/GNOME/etc.) with Xorg as your display server, then Xorg will load this config. And it works too if you connect a new keyboard later. For example, you are working on your laptop on the couch. Then later you want to get back to the desk and connect the external display, keyboard and mouse. Then this will also work for the newly connected keyboard.