Using `hidutil` to Remap Keyboard

I've been using the hidutil function to remap my keyboard which has been useful to prevent double triggering when mapping macros to device keys. Currently the code I'm working with is:

hidutil property --matching {"ProductID":0x024F} --set '{"UserKeyMapping": [{ "HIDKeyboardModifierMappingSrc": 0x700000039, "HIDKeyboardModifierMappingDst": 0x70000007E }] }'

The unfortunate issue I have is that I'm able to use the "ProductID"/"VendorID" of my wireless keyboard to identify it specifically as two of my keyboards possess the exact same product/vendor IDs.

Screen Shot 2022-03-20 at 5.08.46 PM

I'm curious if there is a way to use the "Address" or keyboard name instead of the product ID in the script?

Any help is greatly appreciated!


Beats me. I've never used hidutil to remap keys. I'd be surprised if there was a way to detect the difference, but not astounded.

Thanks anyway! I spent the better part of the weekend searching for a solution but came up empty handed. If I find anything I'll be sure to share it!

1 Like

I stumbled across the answer to my question via trial and error and reading a lot of articles about JSON (which I knew nothing about). The correct code in my situation is:

hidutil property --matching '{"Product":"Keychron K8"}' --set '{"UserKeyMapping": 
              "HIDKeyboardModifierMappingSrc": 0x700000004,
              "HIDKeyboardModifierMappingDst": 0x70000007E

For my purposes I am using this to remap (swallow) all of the keys on one of my keyboards so I can use it exclusively for keyboard maestro macros via device keys without passing the keystroke through! Hope this is of interest and saves someone some time searching for the answer!

1 Like