Caps Lock as Esc & Ctrl

A Clever Bind to Make the Caps Lock Key More Useful

Posted on:

I haven't written anything for my blog in almost a year since setting it up. This is something I'd like to change in the new year, so to start, I thought I'd share something I found useful last year.

Use Caps Lock as ESC + Ctrl

I almost never use the Caps Lock key when it is set to its default function. I guess I just don't do that much yelling on the internet? A couple of years ago, I remapped this key's function to Ctrl, making a traditional keyboard on my laptop or desk behave more like the HHKB. Recently though, I found that it is possible to have the key act as ESC when tapped and released quickly, and Ctrl while held. This gives you the best of both worlds, using ESC for quick Neovim navigation & easy access to the Ctrl key for modifier combinations that require it, like copy & paste.

MacOS Method

I have to start by saying, I don't personally know of a way to do this completely with free software. While that may be possible, I purchased a copy of Better Touch Tool years ago and still happily use it for this and a few other functions.

The first step is to set your Caps Lock key as Ctrl in System Settings > Keyboard > Keyboard Shortcuts > Modifier Keys. Next, head into Better Touch Tool under the Key Sequences / Typed Word menu and click the + button in the main pane. Type the key sequence in the provided box by tapping Caps Lock and releasing the key. Set the max pause to 0.3 and save. In the actions pane, click the + and under the Keyboard Keys heading, find the ESC (Escape Key, respects pressed modifiers) option. That's it! As a bonus, you can also create an additional action for pressing the real Control key + Caps Lock to trigger an action to toggle Caps Lock and keep the ability to use it the few times a year you might actually want to.

Hyprland Method

There are several different ways to do this on Linux. I'm using a method I found on a Reddit thread. I installed ydotool from DNF. Then created a user service to start ydotoold in $HOME/.config/systemd/user/ called ydotoold.service.

Descritpion=Starts ydotoold service

ExecStart=/usr/bin/ydotoold --socket-path="/home/tom/.ydotool_socket" --socket-own="1000:1000"
ExecReload=/usr/bin/kill -HUP $MAINPID


the --socket-path is set to your home directory and the ---socket-own is set to your uid, found with the command echo $UID. Start the service by running systemctl --user enable --now ydotoold. I also added the env variable $YDOTOOL_SOCKET=$HOME/.ydotool_socket to my hyprland config. In hyprland's config syntax, that's done like this: env = YDOTOOL_SOCKET,$HOME/.ydotool_socket.

You can then add the config options from Reddit into your hyprland configs. I have it split into two config files that make the most logical sense for the structure of my config. In my Settings.conf I have:

input {

In my Keybinds.conf I have:

bindr=CONTROL,Caps_Lock,exec, ydotool key 1:1 1:0

That's it! Both platforms I use regularly now have this cool little trick deployed that turns one of the least used keys on my keyboard into one of the most used. If you have any cool productivity hacks like this one that you'd like to share, please feel free to shoot me a message on Mastodon or send me an email.

Tagged with:

More posts: