I have a Microsoft Natural Ergonomic Keyboard 4000. It has a button labelled play/pause. When I have no keyboard drivers installed, the way the button behaves is by toggling playing and pausing in whatever most recent application that supports the behaviour. For example, if my browser is the currently focussed app, but the previously focussed app is iTunes, then the button will play and pause the sound in iTunes. If the previous app was Spotify, the button will trigger in Spotify. The same goes for VLC.

This behaviour of remembering which app to toggle is great and I want to continue using it. I'm now using USB Overdrive to remap the rest of the Microsoft media keys. I am purposely not using the Microsoft keyboard driver because it conflicts with Karabiner which I also use and is compatible with USB Overdrive.

The problem is that in USB Overdrive the default is to set the play/pause button to call iTunes' play command. This breaks the behaviour I described above.

What is the name of the default Mac play function that remembers which app to toggle? Is there a way to run this function from Applescript or Bash? USB Overdrive allows programming a key to launch an application. I believe that the best solution would be to call this function from a script wrapped in a Mac application and link that to USB Overdrive.


It appears that there is a Gist on GitHub using USB Overdrive and a Windows Keyboard that addresses how to map the media keys the way you want to. Configure media keys on a non-Apple keyboard to control Spotify via AppleScript and USB Overdrive on OSX.

If you scroll down to ludalex addition to the Gist, they have added an Applescript that can identify either iTunes or Spotify and assign the Play/Pause key press to the correct app.

  • Interesting solution. It's not exactly the same, but does get you to 80%. – hekevintran Aug 2 '15 at 21:07

I actually found a really simple solution to this problem: delete the play button entry from USB Overdrive and then it won't overwrite the behaviour and everything is as it was for that one button.

Interestingly, this the play key is referred to by Karabiner as ConsumerKeyCode::MUSIC_PLAY. See https://pqrs.org/osx/karabiner/xml.html.en.

  • In addition, I found a solution that does exactly what I want using BetterTouchTool. You can program a key to perform the action Play/Pause (in the Keyboard Keys section of the action menu). – hekevintran Jan 5 '16 at 23:32

You must log in to answer this question.

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