Mac OS Hyper Key

By Dominik Tarnowski on Apr 2025

To remap right command to F18:

hidutil property --set '{"UserKeyMapping":[
  {
    "HIDKeyboardModifierMappingSrc": 0x7000000E7,
    "HIDKeyboardModifierMappingDst": 0x70000006D
  }
]}'

and to persist it, put this in ~/Library/LaunchAgents/com.local.KeyRemapping.plist:

<?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": 0x7000000E7,
              "HIDKeyboardModifierMappingDst": 0x70000006D
            }
        ]}</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

then you can use it to bind things - e.g. with hammerspoon:

hyper = hs.hotkey.modal.new({}, nil)
hyper.pressed = function() hyper:enter() end
hyper.released = function() hyper:exit() end
hs.hotkey.bind({}, 'F18', hyper.pressed, hyper.released)

hyper:bind({}, "1", nil, function()
    hs.application.launchOrFocus("Google Chrome")
end)

Sources