Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Created January 25, 2026 10:41
Show Gist options
  • Select an option

  • Save wilmoore/b6b79e0476bd571e5489de7bbe67fe1c to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/b6b79e0476bd571e5489de7bbe67fe1c to your computer and use it in GitHub Desktop.
Software Engineering :: Operating Systems :: macOS :: Setup :: Guide :: Remap "Caps Lock" to "Control"

Software Engineering :: Operating Systems :: macOS :: Setup :: Guide :: Remap "Caps Lock" to "Control"

⪼ Made with 💜 by Polyglot.

related

Open Safari and navigate to "google.com"; then press Option + Command + c to open the developer console. You'll likely see some janky logs. To clear those out, you can press the Control + l key 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 the hidutil program. Now, going forward, when I'm in the developer console and I want to clear the logs, I can press the caps lock + l and it will function as if I had pressed control + l.

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x7000000E0}]}'
before pressing control + l

after pressing control + l

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
Review
less ~/Library/LaunchAgents/com.local.KeyRemapping.plist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment