Prevent default

Thanks for such a great app!
How to prevent default action for some hardware key? I want to reassign the action for media keys. By default the Play/Pause key launches Music (iTunes). I want to disable this Mac's default action.

Howdy, welcome to the forum! As you might have already figured out, this is a great community full of people who love to help.

Just to clarify, do you still want the media key to play music if there's already an app running; just not launch an app? Or do you want it to do nothing at all? If it's the second option, you could adjust your system keyboard preferences to where you have to use the Function key with them, or you can use KM to "overwrite" those keys.

That can be done by simply writing a macro that doesn’t actually do anything, and assigning it the hardware key you want to overwrite. I have several of these; some for specific applications, others for global hotkeys.

For instance, in Keyboard Maestro sometimes I would hit ⌘R when trying to trigger another macro, and end up recording a new macro. So I made a macro that's available only in KM that does absolutely nothing, but has the ⌘R hotkey so whenever I hit it by accident it does not start recording a macro.

Another example, I have a bad habit of hitting ⌘P when I want to hit ⌘O to open a file and it ends up printing immediately. So I made a macro with a hotkey of ⌘P that when triggered displays a user input box asking me if I really want to print or not. :sweat_smile: From there I can click Print or Cancel depending on how badly I fat-fingered the keyboard.

If you have any more questions, related or unrelated, don't hesitate to ask!


Thank you very much!
Strange thing, but with hardware media key (Play/Pause) it didn't work... The iTunes up continued to react. Fortunately I've found the prompt command to deactivate this behaviour.
Besides that, again, I want to mention that KM is the greatest app ever!

Glad you got it going! But it's odd that your macro didn't work. I just tested one on my computer and if Music (formerly known as iTunes) isn't running, it doesn’t launch. Is/was yours set up in a similar fashion?

Overwrite F8 hardware key.kmmacros (2.7 KB)

Macro screenshot (click to expand/collapse)

If I remember correctly, there are some media keys you can't override. I could be wrong, though.

I set "Use F, F1 etc. keys as standard function keys… (below). Then, if I want to use one of the Apple F1 shortcuts I hold down the function key while clicking the F key.

1 Like

I've been doing that for so long, I forgot it was even an option! Yes, absolutely, I use all the function keys as normal function keys, which means (for my extended keyboard) that there are 19 function keys, times 5 factorial including all the modifier keys (if my math memory is working).

Thanks for reply! No problem with F8, but as it has been discussed, without option "Use F, F1, ..." the exact hardware media key "Play/Pause" is not prevented. No problem with Fs. So to be known for the future...