9

I used the hidutil function to remap several keys on my keyboard:

hidutil property --set '{"UserKeyMapping":
    [{"HIDKeyboardModifierMappingSrc":0x70000003e,
      "HIDKeyboardModifierMappingDst":0x70000004c},
     {"HIDKeyboardModifierMappingSrc":0x70000004c,
      "HIDKeyboardModifierMappingDst":0x70000003e} ,   
     {"HIDKeyboardModifierMappingSrc":0x70000003f,
      "HIDKeyboardModifierMappingDst":0x70000002a},
     {"HIDKeyboardModifierMappingSrc":0x70000002a,
      "HIDKeyboardModifierMappingDst":0x70000003f}]
}'

My problem is that I made some mistakes in it, and I don't find the way to restore it.

1
  • reboot the machine. Commented Feb 15, 2019 at 22:12

3 Answers 3

4

To reset the key mapping(s) back to default, simply make the "destination" the same as the "source"

For example,

hidutil property --set'{"UserKeyMapping": [{"HIDKeyboardModifierMappingSrc":0x70000003e,
  "HIDKeyboardModifierMappingDst":0x70000003e}]'
1
  • Glad it worked for you!
    – Allan
    Commented Feb 15, 2019 at 17:33
16

Passing empty string didn't work for me, i.e. it didn't deactivate existing remappings. However, passing an empty array did the trick.

hidutil property --set '{"UserKeyMapping":[]}'
2
  • 4
    This should be the accepted answer.
    – luckman212
    Commented May 1, 2020 at 21:31
  • [] looks better than "" indeed.
    – clarkttfu
    Commented Jul 8, 2020 at 2:38
1

According to the help doc of the command, the content following --set must be valid JSON. But setting the property to null takes no effect. Instead, I found either empty string actually works here:

hidutil property --set '{"UserKeyMapping":""}'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .