Media Keys Not Working With Spotify or YouTube? Here's Why and How to Fix It
Launch Companion Diagnostic Tool
Test your hardware right now in your browser with zero install:
Open Keyboard TesterYour media keys are almost certainly fine — the problem is that your OS media session handler is routing Play/Pause to the wrong application, or no application at all. Modern operating systems use a single "now playing" session arbitrator (Windows Media Transport Controls on Win10/11, MPRIS2 on Linux, MediaRemote on macOS) that grants control to whichever app last registered an active session. When Spotify is backgrounded and YouTube is playing in a tab, neither may hold the session cleanly, leaving your keyboard's consumer HID codes — Usage ID 0xCD for Play/Pause, 0xB5 for Next Track — with nowhere to land. The physical switches under those keys are standard rubber-dome or scissor mechanisms on most boards; they are not the failure point here.
Confirm Your Keys Are Actually Sending Signals
Before touching any software, verify the keys are transmitting. Open the Keyboard Test and press each media key. Play/Pause, Previous, Next, Mute, and Volume Up/Down should all register. If they do not light up in the tester, you have a real hardware or firmware problem — not a focus issue.
On most TKL and full-size boards the media keys are either dedicated keys wired directly to the USB HID consumer page, or they are Fn-layer combos that require the Fn key to be held or toggled. Check your board's manual for the Fn lock state. Many boards store Fn lock in onboard flash; toggling it is usually Fn + Esc or Fn + F-lock, depending on the firmware. If your board runs VIA or QMK, open the VIA configurator at your board's specific URL and confirm the keycode on that position reads KC_MPLY, KC_MNXT, and KC_MPRV, not a bare KC_NO.
If the Keyboard Test shows the keys firing correctly, the hardware is good. Every step below is software.
Windows: Fix the Media Session Arbitration
Windows 10 and 11 hand media key control to the last app that called SystemMediaTransportControls.GetForCurrentView(). Spotify's desktop client does this on launch. Chrome and Edge both implement the Media Session API (enabled by default since Chrome 73 and Edge 79), so a YouTube tab can also claim the session. When both are running, whichever played audio most recently usually wins, but the handoff is not always clean.
- Open Settings → System → Sound → Volume mixer. Confirm Spotify or your browser is not at 0% application volume and is not muted at the app level.
- In Chrome or Edge, go to
chrome://flags/#hardware-media-key-handling(same path in Edge withedge://flags/). Set it to Enabled. Relaunch the browser. This forces the browser to register its media session with Windows so the OS arbitrator can see it. - If you want Spotify to always win over the browser, go to Spotify desktop → Edit → Preferences → scroll to bottom → Advanced Settings → enable "Allow Spotify to be opened from the web" and keep Spotify running before opening YouTube. Spotify's native SMTC registration takes priority over the browser's when Spotify has an active track paused.
- Restart the Windows Audio Endpoint Builder service: press Win + R, type
services.msc, find Windows Audio Endpoint Builder, right-click → Restart. This clears stale session registrations without a reboot.
Firefox: The Special Case for Keyboard Media Keys Not Working
Firefox keyboard media keys not working with YouTube or Spotify is the most common complaint because Firefox's media key integration is off by default on Windows and partially broken on older Linux builds. Firefox does not use the Chrome Media Session API path; it has its own implementation gated behind a preference flag.
- Type
about:configin the Firefox address bar and press Enter. - Search for
media.hardwaremediakeys.enabled. Set it to true. - Search for
media.mediacontrol.stopcontrol.timer. Default is 3600000 ms (1 hour). If you pause audio and walk away, Firefox releases the session after this timeout. Lower it to 300000 (5 minutes) if you want faster re-registration, or raise it if you want Firefox to hold the session longer between tracks. - Restart Firefox completely (File → Exit, not just close the window, because session processes can linger).
On Linux with MPRIS2, Firefox 81+ exposes an MPRIS2 interface automatically when media.hardwaremediakeys.enabled is true. If your desktop environment's media key daemon (playerctld, mpris-proxy, or KDE's media controller) is not picking it up, run playerctl -l in a terminal to list registered MPRIS players. Firefox should appear as firefox.instance. If it does not, your Firefox binary may be a Snap or Flatpak with D-Bus socket isolation; grant it D-Bus access through your distro's permission tool.
Spotify-Specific Fixes: Desktop App vs. Web Player
| Scenario | Media Key Behavior | Fix |
|---|---|---|
| Spotify desktop, no browser open | Works reliably via SMTC / MPRIS2 | No action needed |
| Spotify desktop + YouTube in Chrome | Keys may jump to YouTube tab | Pause YouTube fully before using Spotify; or disable chrome://flags/#hardware-media-key-handling |
| Spotify Web Player in Chrome | Depends on Media Session API tab focus | Keep the Spotify tab active or pin it; Chrome prioritizes the focused tab's session |
| Spotify desktop, media keys not working spotify after sleep | SMTC session dropped on resume | Restart Spotify; or restart Windows Audio Endpoint Builder service |
| Firefox + Spotify Web Player | Often broken; Firefox media keys not working | Enable media.hardwaremediakeys.enabled in about:config, restart Firefox |
On macOS, Spotify registers with the MediaRemote framework automatically. If media keys spotify not working on Mac, go to System Settings → Keyboard → Keyboard Shortcuts → Function Keys and confirm "Use F1, F2, etc. keys as standard function keys" is off. Also check that no other app (iTunes/Music, QuickTime with an open file) is holding the Now Playing session. Kill them from Activity Monitor if needed.
Frequently Asked Questions
Why do my media keys control YouTube instead of Spotify when both are open?
Whichever app registered a media session most recently with the OS arbitrator wins. YouTube in Chrome registers via the Media Session API the moment audio starts playing. If YouTube played after you last touched Spotify, YouTube holds the session. Pause YouTube completely — not just mute it — so it releases the session back to Spotify.
My media keys work on the keyboard test but do nothing in Windows. What's wrong?
The keys are sending correct HID consumer page codes, but no application currently holds a media session. This happens when Spotify is closed and no browser tab has played audio recently. Launch Spotify or play any audio in a browser tab to register a session, then your keys will have a target. You can verify with the Keyboard Test to rule out hardware at any point.
Does this affect wireless keyboards differently than wired ones?
No. The media session arbitration is entirely in software. Whether your keyboard is wired USB, Bluetooth, or a 2.4 GHz dongle, the HID consumer page codes arrive at the OS the same way. The only wireless-specific issue is if your Bluetooth keyboard loses pairing mid-session, which would look like no keys working at all — not a media-key-only failure.
Firefox keyboard media keys not working on YouTube specifically — is this a known bug?
Yes. Firefox's MPRIS2 and SMTC integration has had inconsistent YouTube support because YouTube does not always call the Media Session API's setActionHandler for Next/Previous, only for Play/Pause. So Play/Pause may work while track-skip does nothing. This is a YouTube-side omission, not a Firefox bug. There is no user-side fix beyond using Chrome or Edge for YouTube if you need full media key support.
Can I assign media keys to specific apps using software?
Yes. On Windows, AutoHotkey v2 lets you intercept the consumer HID codes and route them explicitly. The script hook is Media_Play_Pause:: followed by a WinActivate and Send block targeting Spotify's window class ahk_class SpotifyMainWindow. On macOS, Karabiner-Elements can remap media keys to application-specific shortcuts. On Linux, playerctl --player=spotify play-pause bound to your media key via your DE's shortcut manager achieves the same result.
Should I update my keyboard firmware to fix this?
Only if the Keyboard Test shows the keys are not registering at all. If the keys register in the tester, firmware is not the issue. Flashing firmware on a board that is functionally transmitting correct keycodes carries brick risk for zero benefit in this scenario.
Launch Companion Diagnostic Tool
Test your hardware right now in your browser with zero install:
Open Keyboard Tester