MacOS – How to remap Caps lock to both Escape and Control

keybindingskeyboardmacosshortcut

I generally run Linux. I use Vim a lot, so the Escape key is extremely important. I also use other keyboard shortcuts a lot, so Control is "key" as well. On Linux, I've solved this by using xcape to map the Caps lock key to Escape if pressed by itself, or Control if pressed in combination with another key. This puts the best of both worlds within quick reach of my pinky finger. Is there any way I can do this on a Mac?

Best Answer

Yes, using Karabiner (formerly KeyRemap4Macbook).

First, go into the Keyboard preference pane, click "Modifier Keys…", and change Caps Lock to Control. Then, go into Karabiner and search for this option:

Control_L to Control_L
      (+ when you type Control_L only, send Escape)

Check that, and you're done. With Karabiner you can do lots more interesting things, like mapping your (now kind of useless) Escape key to a Hyper key with even more keybindings.

Related Question