I recently bought Logitech MX Keys: while it’s glorious keyboard there was one annoying thing. For typing polish characters with accent I need to type OPT (ALT) + L for example. OPT in Mac mapping is so far away and Logitech Options app doesn’t allow to remap it. But Mac OS has option to remap this buiilt-in! It is as simple as executing:
hidutil property --set '{"UserKeyMapping":
[{"HIDKeyboardModifierMappingSrc":0x7000000e7,
"HIDKeyboardModifierMappingDst":0x7000000e6}]
}'
The above will reset with every reboot. To make it permanent create file in your home directory:
#!/usr/bin/env bash
hidutil property --set '{"UserKeyMapping":
[{"HIDKeyboardModifierMappingSrc":0x7000000e7,
"HIDKeyboardModifierMappingDst":0x7000000e6}]
}'
Save it as remapkeys.sh, give it executable rights:
chmod +x remapkeys.sh
And add it to login scripts:
sudo defaults write com.apple.loginwindow LoginHook /Users/username/remapkeys.sh
Now change is permanent :)
To find more key codes visit Apple’s documentation archive: https://developer.apple.com/library/archive/technotes/tn2450/_index.html