Make Caps Lock toggle instantly on Linux, without the infamous delay, and without the popular xkb file hack that can leave keys stuck autorepeating.
On Linux (X11 and most xkb-based setups), turning Caps Lock off only takes effect when you physically release the key. If you type fast, your finger is often still on Caps Lock when you hit the next letter, so that letter comes out in the wrong case. To a fast typist this feels like Caps Lock "lags" by one keystroke.
A widely shared solution (for example this Ask Ubuntu answer, based on a Manjaro forum post) edits /usr/share/X11/xkb/symbols/capslock, replacing the ctrl_modifier section with a custom key definition that uses LockMods(modifiers=Shift+Lock, affect=unlock) to apply the unlock on key press.
It does remove the delay, but the lock-state juggling can desync the X server's autorepeat state: a key release event gets eaten while the lock state flips, and the key (space, for example) keeps repeating forever until you press it again. It also gets silently overwritten whenever your distro updates xkb-data.
It uses keyd, a kernel-level key remapping daemon, with a two-line idea:
[main]
capslock = macro(capslock)When you press Caps Lock, keyd immediately emits a synthetic press and release of the key. The release arrives before your next letter no matter how fast you type, so the xkb "unlock on release" rule fires instantly. You keep 100% real Caps Lock semantics: letters only, correct locale behavior (Turkish İ/I works), LED indicator, everything.
A macro_timeout guard makes sure holding the key down does not re-toggle it.
Because keyd works below the display server, this also works on Wayland.
git clone https://github.com/wleeaf/capslock-nodelay
cd capslock-nodelay
./install.shThe script:
- Installs keyd (from your package manager if available, otherwise builds it from source; source build needs
git,make,gcc). - Detects and reverts the xkb
capslockfile hack if you applied it (on Debian/Ubuntu it reinstallsxkb-data). - Removes leftover
caps:*options from GNOME's xkb-options (the old hack required setting "Caps Lock is also a Ctrl" in Tweaks). - Installs the keyd config (backing up any existing
/etc/keyd/default.conftodefault.conf.bak) and enables the keyd service.
./uninstall.shRestores your previous keyd config if one was backed up, otherwise removes the config and stops keyd.
If you already run keyd, just merge keyd/default.conf into your config and run sudo keyd reload.
Zorin OS 17 (Ubuntu 24.04 base, GNOME, X11), keyd v2.6.0. Should work on any systemd distro keyd supports, on X11 or Wayland.