Software Engineering :: Operating Systems :: macOS :: Setup :: Guide :: Remap "Caps Lock" to "Control"
⪼ Made with 💜 by Polyglot.
Open Safari and navigate to "google.com"; then press
Option + Command + cto open the developer console. You'll likely see some janky logs. To clear those out, you can press theControl + lkey combination; however, the "control" key is in such an inconvenient place on the keyboard, especially for someone who uses the control key so often. It turns out, in MacOS it is easy to remap keys so they function as other keys. I rarely yell on the internet, so, I like to remap the "caps lock" key such that it acts as if it were the "control" key. This can be done on the command-line with thehidutilprogram. Now, going forward, when I'm in the developer console and I want to clear the logs, I can press thecaps lock + land it will function as if I had pressedcontrol + l.
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x7000000E0}]}'
hidutil property --set '{ "UserKeyMapping": [] }'
cat > ~/Library/LaunchAgents/com.local.KeyRemapping.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.local.KeyRemapping</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--set</string>
<string>{"UserKeyMapping":[
{
"HIDKeyboardModifierMappingSrc": 0x700000039,
"HIDKeyboardModifierMappingDst": 0x7000000E0
}
]}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
less ~/Library/LaunchAgents/com.local.KeyRemapping.plist

