7

For vim purposes, I'd like to remap CapsLock to CTRL when used in combination with other keys and ESC when used in isolation.

None of the existing solutions give both functionality - only one or the other.

Thanks!

  • Possibly because the key binding is linked to the key-up event, not key-down. I'm guessing, though. – user3463 Jul 4 '12 at 0:04
11

Step by step instructions:

  1. Install both PCKeyboardHack and KeyRemap4MacBook. It will prompt you to reboot after installing the apps.
  2. Disable Caps Lock. Go to System Preferences -> Keyboard -> Modifier Keys. Set Caps Lock to "No Action".
  3. In PCKeyboardHack set Cap Lock to Control_L by changing the Caps Lock keycode to 59.
  4. In KeyRemap4MacBook, toggle "Control_L to Control_L (+ when you type Control_L only, send Escape". I searched for "Control_L escape" and it showed up near the top.

UPDATE:

On High Sierra, this functionality is built into the new Karabiner Elements.

Follow the install instructions, then:

  1. Open Karabiner-Elements
  2. Click "Complex Modifications"
  3. Click "Add Rule"
  4. Click "Import more rules from the internet"
  5. On the resultant web page, look for "Modifier Keys > Change caps_lock Key" and import the configuration.
  6. Profit!
| improve this answer | |
  • Wow, what a great setup. The names of the applications have changed, but it still works! Seil: PCKeyboardHack karabiner: KeyRemap4MacBook – Alex Cory May 8 '15 at 6:00
  • Karabiner-Elements is meant as a replacement to the other packages. It is currently under development and the relevant issue is here and pull request is here. – adarsh Oct 13 '16 at 18:42
  • This fork and solution works for me github.com/tekezo/Karabiner-Elements/issues/… – adarsh Oct 13 '16 at 19:03
4

This worked for me on OSX 10.9:

  1. Set Caps Lock to Control. Go to System Preferences -> Keyboard -> Modifier Keys. Set Caps Lock to "^ Control",
  2. Install KeyRemap4MacBook,
  3. In KeyRemap4MacBook, toggle "Control_L to Control_L (+ when you type Control_L only, send Escape".
| improve this answer | |
0

Try out KeyRemap4Macbook, specifically the part called PCKeyboardHack. A year or so ago I was able to set it up so that holding down Caps Lock worked like Ctrl, but just tapping it brought up Exposé; so what you're asking should be possible.

Configuring KR4M, although it has a GUI, can be a little tricky because of the bewildering variety of options. I think you can probably scroll through the options and just look for ones under "PCKeyboardHack."

Note: I saw someone on IRC say they were unable to get this to work with the Mountain Lion preview; I don't have Lion yet to test out if it works there, but I don't see anything online about it not working (except for this possibly-unrelated bug).

| improve this answer | |
  • I've tried PCKeyboardHack but as you say, the configuration eludes me. I only was able to map CapsLock to ESC, which invalidated the native mapping to CTRL for combination use. – adarsh Jul 4 '12 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.