Skip to content

Instantly share code, notes, and snippets.

@hotrungnhan
Last active August 5, 2022 19:51
Map keyboard macos

ref Apple modifer key map is bull of shit. swap obfucated any key, left to right right to left , dang , then i figure it out how to config it thanks a post. Now to can set it as you want like the guid below.

Macbook keyboard map

Key Code / left right
no action 30064771072
Esc 30064771113
Caps Lock 30064771129
⌃ Control 30064771296 30064771300
⌥ Options 30064771298 30064771302
⌘ Command 30064771299 30064771303
🌐 fn function 1095216660483 280379760050179

Edit Plist

# copy configuration file
cp ~/Library/Preferences/ByHost/.GlobalPreferences.${__UUID__}.plist ~

cd ~ 

## convert it to xml
plutil -convert xml1 .GlobalPreferences.${__UUID__}.plist
## remap key as the map upper

example :

<?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>com.apple.keyboard.modifiermapping.1452-638-0</key>
    <array>
        <dict>
            <key>HIDKeyboardModifierMappingDst</key>
            <integer>30064771300</integer>
            <key>HIDKeyboardModifierMappingSrc</key>
            <integer>1095216660483</integer>
        </dict>
        <dict>
            <key>HIDKeyboardModifierMappingDst</key>
            <real>30064771296</real>
            <key>HIDKeyboardModifierMappingSrc</key>
            <integer>280379760050179</integer>
        </dict>
    </array>
</dict>
</plist>

HIDKeyboardModifierMappingSrc is source key that you want to map HIDKeyboardModifierMappingDst is output key that you want to be

Copy it back

plutil -convert binary1 .GlobalPreferences.${__UUID__}.plist
sudo cp  .GlobalPreferences.${__UUID__}.plist  ~/Library/Preferences/ByHost/.GlobalPreferences.${__UUID__}.plist
rm ~/.GlobalPreferences.${__UUID__}.plist

REBOOT TO UPDATE YOUR PLEASE

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