Skip to content

Instantly share code, notes, and snippets.

@jodoherty
Created March 19, 2023 19:32
Show Gist options
  • Select an option

  • Save jodoherty/b274e1261094f11f641277d28f33b5ff to your computer and use it in GitHub Desktop.

Select an option

Save jodoherty/b274e1261094f11f641277d28f33b5ff to your computer and use it in GitHub Desktop.
Remapping MacBook pro keys

This hidutil command remaps the following keys on the internal MacBook Pro keyboard:

  1. caps lock is remapped to esc
  2. right command is remapped to right option
  3. right option is remapped to right ctrl

I use these remappings because I spend most of my time working in the terminal or in Emacs, so having an extra command key is less important to me than having symmetric left/right ctrl and option keys.

To use com.local.KeyRemapping.plist, place it in ~/Library/LaunchAgents/

<?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>--matching</string>
<string>
{
"ProductID":0x342,
"VendorID":0x5ac
}
</string>
<string>--set</string>
<string>{"UserKeyMapping":[
{
"HIDKeyboardModifierMappingSrc": 0x7000000E6,
"HIDKeyboardModifierMappingDst": 0x7000000E4
},
{
"HIDKeyboardModifierMappingSrc": 0x7000000E7,
"HIDKeyboardModifierMappingDst": 0x7000000E6
},
{
"HIDKeyboardModifierMappingSrc": 0x700000039,
"HIDKeyboardModifierMappingDst": 0x700000029
}
]}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment