My keyboards fn
key is on the right side rather than the left, and my mac isn’t registering my right-fn
key presses at all, so I basically don’t have a fn
key.
I hardly use my right-ctrl
key, so I remapped it to fn
with hidutil
:
# Get current key mapping
$ hidutil property --get "UserKeyMapping"
(null)
# Remap right_control --> fn
$ hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc": 0x7000000E4, "HIDKeyboardModifierMappingDst": 0xFF00000003}]}'
# Now we see a populated mapping
$ hidutil property --get "UserKeyMapping"
(
{
HIDKeyboardModifierMappingDst = 1095216660483;
HIDKeyboardModifierMappingSrc = 30064771300;
}
)
# You can clear any mappings with:
$ hidutil property --set '{"UserKeyMapping":[]}'
And now I have a working fn
key 🎉
The above won't last through a reboot, however. To make it stick, I created a launch agent that runs at load. See attached plist definition.
# Load definition into launchd
$ launchctl bootstrap gui/${UID}/ ~/Library/LaunchAgents/com.${USER}.reMapRightCtrl
# Turn it on
$ launchctl enable gui/${UID}/com.${USER}.reMapRightCtrl
# Run it once, immediately
$ launchctl kickstart gui/${UID}/com.${USER}.reMapRightCtrl