Remapping right control key to right option in Mac
Hey!
I arrived to this subreddit looking for a way to remap the right control key on my new keychron to a right option. That way it's easier to write characters like # or €.
I found this post, where u/fisz91 mentioned a blog post where the process was described. With that information I build the solution that is currently working great for me.
It's very simple. Two steps:
Using
hidutil
, remap the keys for the current session. Run this on the terminal:
hidutil property --set '{"UserKeyMapping":[
{
"HIDKeyboardModifierMappingSrc": 0x7000000E4,
"HIDKeyboardModifierMappingDst": 0x7000000E6
},
]}'
2. To make it persistent after reboot, you need to create the file ~/Library/LaunchAgents/com.example.KeyRemapping.plist
, with the following contents:
<!--
Put this file in ~/Library/LaunchAgents/com.example.KeyRemapping.plist to
automatically remap your keys when macOS starts.
See https://developer.apple.com/library/archive/technotes/tn2450/_index.html for
the key "usage IDs". Take the usage ID and add 0x700000000 to it before putting it
into a source or destination (HIDKeyboardModifierMappingSrc and
HIDKeyboardModifierMappingDst respectively).
The remapping makes the right control behave as a right option.
-->
<?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.dgrcode.KeyRemapping</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--set</string>
<string>{"UserKeyMapping":[
{
"HIDKeyboardModifierMappingSrc": 0x7000000E4,
"HIDKeyboardModifierMappingDst": 0x7000000E6
}
]}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>