5

I've had the (mis)fortune to get a new work laptop with the O' so great Touch Bar which I so immensely hate and have changed the Touch Bar to display F-keys.
However one thing I do miss is my global Media Keys. I'm primarily listen to Spotify and I know it has shortcuts but that requires me to make the Spotify window active which it rarely is.

I've looked into both Google and the shortcut options Apple provides me and I have yet to find a way to set up a global shortcut for the Media Keys (Next, Prev. Play/Pause)

Any help or suggestions would be greatly appreciated.

4 Answers 4

3

This solution is a bit of a workaround, but I think that it should work for you.

First, you can write some AppleScripts that will perform the actions Next, Prev., and Play/Pause. I found some examples here. If you are on macOS Catalina, you will need to replace "iTunes" with "Music", unless you only use Spotify and don't want to check for other open applications.

Next, you can create a Quick Action (also known as a service) in Automator. I found some instructions to do that here.

For each AppleScript (Next, Prev, Play/Pause), you can either save it as an application, and set the service to open that application, or you can have your service run the AppleScript directly by using the Run AppleScript variable in Automator.

When you save each service, give it a name (like next, prev, and play), as that will be what shows up in the shortcuts menu.

Now that you have 3 services, you can go to System Preferences -> Keyboard -> Shortcuts -> Services. You can now set a keyboard shortcut to run each service, which in turn should run the AppleScript to perform the Media Action you want. The services you just made should be in the General section, which is at the very bottom of the list for me.

6
  • Hi Beninto, thanks for your reply. It was very helpful and does actually works very well. Now my next challenge is to get those goddamn shortcuts to work but that's a separate issue :-) Thanks again 👍
    – Mestika
    Dec 9, 2019 at 7:07
  • @Mestika No problem. What about the shortcuts aren't working? Are you having an issue adding them in System Preferences?
    – beninato
    Dec 9, 2019 at 8:35
  • Well for some reason the service do not response. The service works when running it manually but not via the shortcut. Both the automator and finder has been added to accessibility privacy.. It's a bit weird
    – Mestika
    Dec 9, 2019 at 9:15
  • @Mestika I would double check that you have the workflow input set to "no input" and in "any application", and that the shortcut you set doesn't have any conflicts (so maybe test it with something like command+option+control+shift+x). Other than those issues, I don't really know how to help you fix it.
    – beninato
    Dec 9, 2019 at 9:33
  • @Mestika Do you have the check box selected in System Preferences -> Keyboard -> Shortcuts -> Services for the service you created?
    – beninato
    Dec 10, 2019 at 19:13
6

With the advent of Shortcuts on macOS Monterey, you don't need so many steps now.

You need to just create a shortcut which runs the macOS Play/Pause action and then make it a Quick Action, check Finder, and set your keyboard shortcut.

Here is an example shortcut I created: https://www.icloud.com/shortcuts/aa8c4a50ec5d4960a6e05893cda51ccf

On Ventura, you can do this all within the Shortcuts app. Launch it, then search for "pause", and assign the "Run with" keyboard shortcut you want. You also won't need to select Finder anymore; you can instead leave Services Menu as the default checked item. Here's what it looks like when you're done in Shortcuts:

screenshot of the setup in MacOS Ventura

3
  • 1
    Can you add a screenshot showing the shortcut steps, so the answer stays useful even if you remove the shortcut later?
    – nohillside
    Nov 1, 2021 at 9:48
  • I would personally love to see the steps, yes :-)
    – Mike Hardy
    Dec 17, 2021 at 16:07
  • 3
    @nohillside Step 1 : Go to shortcuts app Step 2: Create new Shortcut using the + icon on top right. Step 3: On right menu under Action Library✨, Under Categories TAB, Choose media🎵 Step 4: Scroll down to Playback section(Not Music Section) & drag one of play/pause or Skip Forward or Skip Back to the editor section on the left. Step 5: Go to Shortcut Details section(with tuning icon) and click on Add Keyboard Shortcut and add your preferred keyboard shortcut.
    – Saharsh
    Feb 7, 2022 at 20:27
2

I had a similar problem, using a basic, non-apple, USB keyboard pressing F8 wouldn't pause my music whether or not I checked the "Use F1, F2, etc. keys as standard function keys" option.

I spent a while trying to get Applescripts to control Chrome but it was more complicated than controlling Spotify.

What ended up helping was installing Karabiner-Elements. Without any extra configuration, now pressing F8 works to control media.

1
  • 1
    Karabiner Elements works like a charm and allows you to do a whole lot more with your function keys if you are using a standard (external) keyboard at home. Thanks for the suggestion Carl!
    – saurabhj
    Oct 8, 2021 at 10:44
1

Everything in @beninato's answer worked for me. The only thing I had trouble with was that when setting the keyboard shortcut for the services I created, it had to include the command key for the service to be run by the shortcut.

Maybe that was your issue @Mestika?

You must log in to answer this question.

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