Apple - How can I remap Caps lock to both Escape and Control?
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.
Karabiner is currently incompatible with MacOS Sierra. Another, Sierra-friendly solution, is with Keyboard Maestro (it is not free). Change the behavior of the Caps-Lock key to Control through System Preferences
-> Keyboard
-> Modifier Keys
as others have suggested.
Then within Keyboard Maestro, setup a macro as follows:
- Triggered by
USB Device Key Trigger
- Press the Caps-Lock key on your keyboard
- is tapped once
- with these modifiers:
^
- (you will need to repeat the previous trigger for each USB keyboard you use)
- Then add an action
Text
->Type a keystroke
- Press Esc
To do it with Karabiner Elements, which supports macOS 10.12 and later, open ~/.config/karabiner/karabiner.json
, and add the following rule to the rules
array.
{
manipulators: [
{
description:
"Change caps_lock to control when used as modifier, escape when used alone",
from: {
key_code: "caps_lock",
modifiers: {
optional: ["any"]
}
},
to: [
{
key_code: "left_control"
}
],
to_if_alone: [
{
key_code: "escape",
modifiers: {
optional: ["any"]
}
}
],
type: "basic"
}
]
}
You can also try to use ControlEscape.spoon with Hammerspoon.