Customize Modifiers?

Is it possible to customize modifier keys by themselves? I'd like to block the Command key altogether in one app, and map another regular key to behave as a modifier.

Out of the box BTT can't do this.

You might be able to use the triggers "Specific App Did Activate" and "Specific App Did Deactivate" (from the named & other triggers section) in combination with a shell script or terminal command that runs hidutil to do a remapping.

For example this command would remap left cmd to left opt:

/usr/bin/hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x7000000E3,"HIDKeyboardModifierMappingDst":0x7000000E2}]}'

And this one

/usr/bin/hidutil property --set '{"UserKeyMapping":[]}'

Should reset it.

More information on how to use hidutil is available here: Technical Note TN2450: Remapping Keys in macOS 10.12 Sierra

If you have a concrete example I can tell you how to do it

Thanks so much for the quick response Andreas!!

Hmm, I think for remapping a regular key to a modifier, I'll stick with Karabiner in that case. But I am looking for a way to block the Command key when using Microsoft Remote Desktop (so I don't keep accidentally bringing up the Windows menu when using Command+Tab to switch back and forth from the app). Is that possible with the method you mentioned?

/usr/bin/hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000000E3,"HIDKeyboardModifierMappingDst":0x700000000}]}'

Would disable (left) cmd.

Then when the app deactivates calling this would reset the remappings again

/usr/bin/hidutil property --set '{"UserKeyMapping":[]}'

I just tried this with safari and it seems to be working fine:

1 Like

Thanks Andreas!!