Vivek Haldar

Remapping arbitrary keys in Mac OS X

Just thought I’d put this tip out in the Internet…

So I recently got a Thinkpad Trackpoint II keyboard, which I like to use with my MacBook when docked to an external monitor. Yes, I realize that’s mixed up.

But it happens to have a “PrtSc” key right on the space-bar row that is perfectly placed to be the “Cmd” key. Mac OS X, in its Keyboard Preferences, lets you remap some standard keys (Caps Lock to Ctrl, for example), but not PrtSc.

Following this documentation, this is the command I ended up with to map PrtSc to Cmd:

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000046,"HIDKeyboardModifierMappingDst":0x7000000E7}]}'

The keycode for PrtSc is 0x46, and for “Right GUI” aka Cmd is 0xE7, and you have to OR them into 0x700000000.