The possible usage scenario is
-
Determine an unused key on the keyboard
-
Check the documentation at Technical Note TN2450: Remapping Keys in macOS 10.12 Sierra
-
Determine the trigger key. E.g. caps lock. Check its
hexcode. Or Use skhd to gethexcode of any key on the keyboard using the following command:
skhd -oFree hidutil file generator
- Prepare a
.jsondocument:
{
"UserKeyMapping":
[
{
"HIDKeyboardModifierMappingSrc": 0x700000039,
"HIDKeyboardModifierMappingDst": 0x700000073
}
]
}- Run
hidutil property --set "$(cat ~/capslock_to_f19.json)"- Check if it is working properly;
hidutil property --get "UserKeyMapping"The caps lock key must not work any more. Debug it through skhd -o command.
Disabling Key Mapping
By default when you restart the system, keymappings are deleted by default. If you don’t want to restart the system, you can use the following command:
hidutil property --set '{"UserKeyMapping":[]}'