A Great Remapping of Caps Lock

2025-07-07

Since I started using NeoVim and tmux I find I’m a lot more conscious about the ergonomics of each keypress, especially the ones I do a lot of. For tmux I set the leader to be Ctrl+s, which was forcing me to stretch my pinky too much for my taste.

One common solution I’ve seen is to remap Caps Lock -> Control. You still have to use your pinky, but at least you’re not leaving the home row. The problem is that I’m the shameful owner of a MacBook Pro with a touchbar (I bought it for €400 from an old job, decent deal), this means I don’t have a physical Escape key, so having Caps Lock -> Escape is mandatory for my setup. I was about to give up when I had an idea:

I only tap Escape and I only hold down Control, would it be possible to remap Caps Lock to do both?

I asked Claude and you can do this with the almighty Karabiner-Elements and a very simple config:

{
  "description": "Change caps_lock to control if pressed with other keys, to escape if pressed alone",
  "manipulators": [
    {
      "from": {
        "key_code": "caps_lock",
        "modifiers": {
          "optional": ["any"]
        }
      },
      "to": [
        {
          "key_code": "left_control"
        }
      ],
      "to_if_alone": [
        {
          "key_code": "escape"
        }
      ],
      "type": "basic"
    }
  ]
}

Having Claude spit this out pretty much tells me I’m not the only one who thought of this, but I’ll take it. I’m also aware that some Vim users remap Escape -> jk, which is something I might try. I’m sure Karabiner-Elements has me covered.