Keep Play Pause on Keyboard Linked To Music

If I am playing music on my Mac (which is basically always when I am working on my Mac and not in meetings) and I need to play a video somewhere else (say Youtube), I click the play button in the browser and video starts to play. So I then click Play / Pause on keyboard. What I would like to happen at this time is the music pauses. Unfortunately, it pauses the YouTube video (or whatever video is playing). That is never what I want to happen.

I searched and didn’t see if this was answered already (sorry if I missed it) but is there a way to make sure play pause on keyboard ONLY ever controls music?

I also don’t like that if I am in keynote working on a presentation and it takes over the play pause keyboard keys too. I only ever want those keys to control the music app. Anyone know how to do that?

1 Like

There used to be tiny apps for this like High Sierra Media Key Enabler, Mac Media Key Forwarder, and BeardedSpice but I don’t know any that work on my M1 MacBook Air.

Alas, all three seem to be abandonware.

There was also a Karabiner Elements rule that I could not get to work. :frowning:

So I wrote a simple AppleScript to play/pause Music that I added to FastScripts and trigger via a hotkey combo. I’m sure it could be triggered by other utilities as well.

1 Like

This doesn’t directly solve your problem in the way you would like it to, so I apologize and I understand your frustration.

What I’ve done to alleviate the problem is run Alfred and Powerpack (Alfred’s paid version). That gives me the ability to hot-key the Music app to Control + Command + Return. That’ll give me the UI in the screenshot below.

At that point, I just start typing “pause” until Alfred lets me pause the music with a quick keystroke.

Obviously, this is way more steps than just hitting the Play/Pause button. 150% agreed, and I would prefer it to work your way. But this at least makes it so I don’t need to take my hands off the keyboard for this mundane task.

1 Like

Yeah, that’s frustrating and I’ll be interested to see if you find a good solution.

I have the same issue, but the reverse of you. I listen to music in Plex in a browser tab all day. Sometimes, I think when it’s been paused for a long time?, I’ll hit the play button on my keyboard and instead of resuming the music in plex it will open the Music app and start playing something randomly from there. Pretty frustrating.

As an interesting coincidence, I had Dream Theater playing when I read this. :slight_smile:


They just played Atlanta. Not my bag, but they are admittedly so good at what they do.

They just played two places close to me, although I did not go. And while I wouldn’t have them as the top item on my list as snelly does, (Pink Floyd and Brian Eno would be at the top) there is some of their stuff I enjoy. One of the few bands that Apple Music suggested that clicked with me.

1 Like

Woah woah woah now, they are not at the top of my list. Let me defend my taste! :wink: But I do like a couple albums of theirs from the 90s.

They just happened to be the random album that Alfred picked this morning when I hit the “random album” button and it vibed with me this morning.


And now that I’m using Touch Portal, I’ve added a button to run that play/pause AppleScript.

So while I’d prefer to have the keyboard key always target Music, I’ve got an acceptable workaround.

And this is the aforementioned AppleScript:

tell application "Music"
end tell

As I said, pretty simple.

Could you rig this up to Keyboard Maestro and assign it to run every time you hit the Play/Pause key? Because that’d be the solution for sure.

Maybe. I’ve only recently started using Keyboard Maestro, and am by no means an expert.

But as the forecast calls for rain this weekend in these here parts, I may be stuck inside so it seems I’ve got a project (more fun than yard work!).

Of course, if I had one of those QMK programmable keyboards … (quick, hide my wallet …)

1 Like

I’d love to know how to do this. As far as I can tell, Apple has locked away control of these keys so KM etc cannot use them…

… but while writing this I had a cunning plan.

  1. Switch to use the function keys instead of media keys
  2. Program KM to mimic the media key functions or my preferred variation when the Fn key is pressed

The problem I foresee is I don’t know if I can use KM to bring up Mission Control, but I’ll give it a go.

I found a solution, so I created an account just to share for those who may come across this :blush:

For Chrome:

  1. In the URL box type: chrome://flags/
  2. Search for Hardware Media Key Handling
  3. Set that to disabled
  4. Restart Chrome

For Firefox:

  1. In the URL box type: about:config
  2. Proceed
  3. search for the entry “media.hardwaremediakeys.enabled”
  4. click the button to the right to change the value to ‘False’
  5. No Firefox restart required

I think this is something that must be embedded in Apple OS, because I run a mechanical keyboard that’s coded via QMK and even though my play/pause button is specifically scripted to play/pause music, if I put a video on the button automatically controls that too, even though it’s not coded to do so (by me at least!). It is frustrating.

What bugs me though is that if you’re on an iOS device, iOS automatically pauses and then resumes your music while you watch a video, so clearly Apple are aware we don’t like music playing while we watch a video, but hasn’t made this easy on MacOS :thinking:

I recently started using Reflex and so far it is working well for me.

1 Like

Reflex installs nicely and looks good on my M1 MacBook Air. And, even better, it is working perfectly to control the Apple Music app!

Now if only someone could come up with a way to keep the Mac Music app (rewritten as a Catalyst app on the Mac) to keep playing. It often seems to lose its place, doesn’t correctly show the currently playing song, and then just stops playing partway through a playlist. :upside_down_face:

I use a combination of Keyboard Maestro and Karabiner Elements to do this.

Keyboard Maestro has 3 macros running simple AppleScripts telling Apple Music to Previous Track / Play-Pause / Next Track, set to F18, F19, F20 respectively. E.g.

For Previous Track, replace playpause with previous track; for Next Track, replace it with next track.

(This is the same AppleScript which @MevetS describes above.)

Karabiner Elements simply binds F18-20 to F7-9, and therefore overwrites the built in Function Key commands:

That’s it. It works very well, particularly as I don’t use the function keys to watch videos – there’s no need when YouTube has built in shortcuts anyway.