190

My USB keyboard does not have "media" keys -- that is, dedicated keys for play, stop, next, prev, volume up/down, etcetera.

Keyboard media keys

For the sake of this question, I would prefer not to install additional software if I can avoid it.

Is it possible to issue some standard key sequence on a generic USB keyboard that emulates these play, stop, etc. multimedia keys?

Like Ctrl+Alt+Shift+F12 or something obscure like that?

6
  • also, depending if you use the Windows Sidebar, there may be a Gadget availible for media player controls...
    – tombull89
    May 4, 2011 at 11:21
  • o/s ? for linxu gconf can do it.
    – Sirex
    May 4, 2011 at 13:41
  • related: superuser.com/questions/278369/… May 5, 2011 at 5:07
  • for the niche users that wouldn't consider a browser addon 'additional software' and you listen to most of your music on youtube, streamkeys works well for even for hotkeys when toggled outside of chrome. Works under windows 10, I would guess this is also mostly OS independent. Jan 18, 2021 at 13:24
  • 2
    The modern real solution to this is QMK/VIA which allows permanently re-programming a keyboard. But, you would need a new keyboard that supports QMK/VIA. However, Microsoft PowerToys's includes a "Keyboard Manager" that can map any key to or key-combination to media control keys. It does require install PowerToy's which is quite simple.
    – Marquez
    Jul 24, 2022 at 17:54

16 Answers 16

39

I'm pretty sure it's not possible to do what you want. Media keys don't send key combinations; instead, they have their own usage IDs in the HID. See this document (media keys are in the Consumer Page (0X0C)). If you want to simulate them using a key combo, you're going to have to do it in software.

0
209

Windows

AutoHotkey

AutoHotkey (AHK) is a free, open-source macro-creation and automation software for Windows that allows users to automate repetitive tasks. It is driven by a scripting language that was initially aimed at providing keyboard shortcuts, otherwise known as hotkeys, that over time evolved into a full-fledged scripting language.

http://ahkscript.org/

To learn about AHK I recommend checking its site, pages mentioned in Quick Reference and especially skimming at least AutoHotkey Beginner Tutorial. Don't forget to download, install and fiddle with it yourself. There is also helpful forum.

Example

In this case you should look particularly at following pages: Hotkeys (Mouse, Joystick and Keyboard Shortcuts), List of Keys, Mouse Buttons, and Joystick Controls and Send / SendRaw / SendInput / SendPlay / SendEvent: Send Keys & Clicks. Then you'll be able to assemble simple AHK script, e.g. something like:

^!Left::Send   {Media_Prev}
^!Down::Send   {Media_Play_Pause}
^!Right::Send  {Media_Next}
+^!Left::Send  {Volume_Down}
+^!Down::Send  {Volume_Mute}
+^!Right::Send {Volume_Up}

^!.::
MsgBox, 0, , Hello AHK world!
return

Here you define following actions:

  • Ctrl+Alt+ sends Previous
  • Ctrl+Alt+ sends Play/Pause
  • Ctrl+Alt+ sends Next
  • Ctrl+Shift+Alt+ sends Volume Down
  • Ctrl+Shift+Alt+ sends Mute
  • Ctrl+Shift+Alt+ sends Volume Up
  • Ctrl+Alt+. invokes message box greeting AHK world (just to show non-oneline key-commands mapping ending w/ return)

Usage

You create .ahk file, paste above code in it (w/o useless MsgBox, of course), save and double click to run it. You'll get H icon in systray allowing you to interact w/ the script, particularly: suspend hotkeys, pause script (not useful here) or just exit it. For better convenience I suggest compiling such script. You can do it using Right Button Mouse on the file and choosing Compile Script. Then you'll get .exe file (pretty big, but it's like complete autohotkey) that you can share w/ others or add to autostart for instance.

Remapping via the Registry's "Scancode Map" / KeyTweak

In AutoHotkey's Remapping Keys and Buttons page you can read about other way of assigning keys to keys, remapping. It may be not useful in your case (unless you're ready to "lose" some keys), but it's still worth reading. (Then you should figure out why I haven't used AHK remapping in my example.)

Let me quote it (w/o blockquote to preserve formatting) and fix some links along the way:

<quote>

Advantages

  • Registry remapping is generally more pure and effective than AutoHotkey's remapping. For example, it works in a broader variety of games, it has no known alt-tab issues, and it is capable of firing AutoHotkey's hook hotkeys (whereas AutoHotkey's remapping requires a workaround).
  • If you choose to make the registry entries manually (explained below), absolutely no external software is needed to remap your keyboard. Even if you use KeyTweak to make the registry entries for you, KeyTweak does not need to stay running all the time (unlike AutoHotkey).

Disadvantages

  • Registry remapping is relatively permanent: a reboot is required to undo the changes or put new ones into effect.
  • Its effect is global: it cannot create remappings specific to a particular user, application, or locale.
  • It cannot send keystrokes that are modified by Shift, Control, Alt, or AltGr. For example, it cannot remap a lowercase character to an uppercase one.
  • It supports only the keyboard (AutoHotkey has mouse remapping and some limited joystick remapping).

How to Apply Changes to the Registry

There are at least two methods to remap keys via the registry:

  1. Use a program like KeyTweak (freeware) to visually remap your keys. It will change the registry for you.
  2. Remap keys manually by creating a .reg file (plain text) and loading it into the registry. This is demonstrated at www.autohotkey.com/forum/post-56216.html#56216

</quote>

EventGhost

EventGhost is an advanced, easy to use and extensible automation tool for MS Windows. It can use different input devices like infrared or wireless remote controls to trigger macros, that on their part control a computer and its attached hardware. So it can be used to control a Media-PC with a normal consumer remote. But its possible uses go much beyond this.

http://www.eventghost.org/

Haven't tried it, but looks interesting and a bit related, so I think it's worth mentioning it here.

Some SuperUsers may remember Girder, that unfortunately stopped being freeware long time ago. EventGhost seems somewhat similar. I no longer have AverMedia's TVPhone98, but using remote via Girder was fun.

10
  • If the shortcuts don't work, a Chrome App (such as Google Music) may be hijacking them. Have a look at the bottom of the Extensions page in Chrome, there's a "Keyboard shortcuts" link where you can disable them.
    – isanae
    Apr 5, 2017 at 0:45
  • You may want to add that AutoHotkey is considered a cheat by certain anticheat systems and as such doesn't work while gaming or can downright get you banned.
    – Darkhog
    May 7, 2017 at 20:35
  • KeyTweak seems like the shortest route to a simple solution...
    – O'Rooney
    Jul 4, 2017 at 22:18
  • 2
    AutoStart can also be achieved by simply putting the .ahk file into autostart folder (Run: shell:startup)
    – N4ppeL
    Sep 27, 2018 at 14:20
  • I managed to get Autohotkey to do it with just: ^Right::Media_Next
    – Sam Tolton
    Aug 15, 2019 at 9:25
40

Another option (for laptops) is to setup your touchpad finger gestures in Windows 10. You can choose to change the settings for three-finger and/or four-finger gestures.

Settings > Devices > Touchpad

Below is how I set mine up since I don't have media keys. Although this isn't exactly what was asked for, this solution is great since you don't need any extra software. Some might find it more convenient than a keyboard shortcut.

An screenshot of Microsoft Windows four-finger gesture settings for the touchpad. In the image, the settings are set so that up and down swipes control the volume, right and left swipes change the track, and four finger taps play and pause the audio

4
  • 6
    This isn't the answer, but it's a perfect solution for me! Would have never thought of doing this!
    – Geoff
    Jul 26, 2021 at 8:09
  • You can also define in advanced gestures under touchpad (found in Win 11, not sure about 10, probably the same) 4 fingers tap on mousepad as play/pause - exactly what you're looking for (I myself implemented above solution along with this little trick i proposed. No additional software, no macros etc. just definitions Jan 24, 2022 at 2:11
  • This is a viable solution to the problem on Windows 10, if not the question, specifically. Mar 25, 2022 at 20:08
  • This is absolutely a viable solution to the question. Touchpads have always been common on USB keyboards and this is a generic solution without the need to install additional software (besides Windows 10+ if you don't have it, though the other answers assume Windows is installed as well). At this point, a multitouch touchpad input is standardized. The only caveat is that it's not not coming from keyboard "keys" and thus will not work on every USB keyboard. Since it will work for the vast majority of keyboards, this is actually a better answer than most others.
    – Pluto
    Nov 11, 2022 at 16:54
14

If you have some useless keys, (like scroll lock, or pause, or the key to invoke the contextual menu, or the windows key at the right side, or else) you can remap it to media keys.

Windows: with Sharpkeys.

Mac: with Karabiner

11

Windows Powertoys Keyboard Manager allows you to define such shortcuts.

My keyboard does have Pause/Play, decrease and increase volume and mute. But it's missing previous and next track, so I've created the following shortcuts:

shortcuts for previous and next track in Windows Power Toys Keyboard Manager

8

I don't blame you for not wanting to install extra software, but AutoHotKey is a program which lets you write scrips for key presses.

AutoHotkey is a free, open-source utility for Windows. With it, you can:

  • Automate almost anything by sending keystrokes and mouse clicks. You can write a mouse or keyboard macro by hand or use the macro recorder.

  • Create hotkeys for keyboard, joystick, and mouse. Virtually any key, button, or ombination can become a hotkey.

  • Expand abbreviations as you type them. For example, typing "btw" can automatically produce "by the way".

  • Create custom data-entry forms, user interfaces, and menu bars. See GUI for details.

  • Remap keys and buttons on your keyboard, joystick, and mouse.

  • Respond to signals from hand-held remote controls via the WinLIRC client script.

  • Run existing AutoIt v2 scripts and enhance them with new capabilities.

  • Convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed.

7
  • also, slighty going off, does your media player come with keyboard shortcuts? i.e. iTunes has a large shortcut list.
    – tombull89
    May 4, 2011 at 10:37
  • +1 for AutoHotKey which I would use for that too. Here are some scripts that seem to emulate Media Keys: autohotkey.com/forum/topic7135.html
    – slhck
    May 4, 2011 at 10:41
  • @Ivo, .bat files are the limit of my programming ability so unfortunately asking me to write even a sample script would be a while coming.
    – tombull89
    May 4, 2011 at 11:18
  • If you were to use a free OS, you could use xmodmap in xorg. Not posting as an answer because I read Jeff Atwood'd blog and know the odds of his dropping Windows approximate zero.
    – CarlF
    May 4, 2011 at 12:42
  • AutoHotkey is very good. But it has too steep learning curve. I don't want to spend hours learning to use a tool, to do simple tasks.
    – Calmarius
    Oct 13, 2012 at 20:40
6

As others have said, AutoHotkey can help in this case greatly. For example, this script will remap Previous/Next buttons to Winkey + < / >, Volume Down/Up to Winkey+ [ / ] and Mute Toggle to Winkey+ \ . For Play/Pause, Space bar works anyway by default in YouTube by default and in desktop players like MPC-HC / MPC-BE / VLC. Just for Windows Media Player, you can remap Ctrl+P (default for Play-Pause) to Space.

; AutoHotkey Multimedia Keys
#,::Send {Media_Prev}
#.::Send {Media_Next}
#\::Send {Volume_Mute}
#]::Send {Volume_Up}
#[::Send {Volume_Down}
#IfWinActive ahk_class WMPlayerApp
Space::Send {Media_Play_Pause}

Now your keyboard has multimedia keys :)

4

Many media player applications have support for "Global Hotkeys" -- key combinations that allow you to play/pause, go to next track, etc. from anywhere on your computer. (Many of the Ctrl / Alt / Shift / Option combinations have already been claimed by other software, but the Win / Super / Meta key combinations are relatively open.)

For example, I'm running Songbird and I've mapped Win+NumPad0 to play/pause, while Win+NumPad4 and Win+NumPad6 are previous track and next track respectively.

Check to see whether your preferred media player natively supports global hotkeys (and if it doesn't, get a better one).

1
  • 3
    In many ways this is really the best solution if the aim is only media control. (Foobar2000 supports global hotkeys too)
    – DetlevCM
    May 31, 2015 at 13:50
2

This isn't a complete answer to your question since it is likely too specific but it may contain some useful information so I am passing it along:

I do it like this using fluxbox and ogg123 - I have this in .fluxbox/keys

# Control ogg123
Mod4 p :Exec killall -STOP ogg123       # pauses ogg123 
Shift Mod4 p :Exec killall -CONT ogg123 # unpauses ogg123
Mod4 o :Exec killall -INT ogg123        # skips tracks in ogg123
Mod4 Shift o :Exec killall ogg123       # stops ogg123

# Control volume
Mod4 = :Exec amixer sset Master,0 1+
Mod4 - :Exec amixer sset Master,0 1-
Shift Mod4 = :Exec amixer sset Master,0 toggle
2

Windows 10 has quite robust Speech Recognition. Set it up and activate it, then use these commands to control media:

switch [name of open media software]
next
previous
pause
play
volume, press right
volume, press left

You don't need to say the entire name of the software: switch media player is enough to switch to switch to Windows Media Player; switch cast is enough to switch to Windows' Cast to Device media casting tool.

To find out what commands you can use in an open window, you can hover over the buttons with your mouse, and check the tooltips. If there's no tooltip, you can say show numbers, and a matrix of numbers will overlay over any actionable elements on your screen.

2

I found that "Snip" software not only displays current song played but also allows you to control your player. It currently supports: Spotify, iTunes, Winamp, foobar2000, VLC, Google Play Music Desktop Player, Quod Libet

Take a look at https://github.com/dlrudie/Snip

2
  • Sure, this is always when one tries to help. I was in same situation as he was. Found this thread. The accepted answer was useless to me I was searching further and found different solution. Internet use to be better place ten years ago. Your comment certainly adds value too, right?
    – richo
    Feb 23, 2018 at 10:20
  • I'm glad this thread assisted you with your own problem. The thing is, SuperUser is about specific questions and specific answers. Because in your circumstances using third-party software was acceptable, then you have a different question. If there is not a question dealing with your specific question, you can actually post your own question and then answer it yourself. THAT is perfectly acceptable and even encouraged, plus it is more likely to gain your more reputation. Don't hate this game, understand it. Feb 23, 2018 at 16:48
2

In case anybody still struggle with this, Microsoft PowerToys provides a powerful tool for this. You can map any keyboard combinations to control Media (Play/Pause, Volumn up/down/mute). I mapped Ctrl+Alt+Home for Play/Pause, Ctrl+Alt+Up/Down for volumn Up/Down and very comfortable with it. Hope it helps

1
  • 1
    Welcome to Super User! Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also tour for the site tour, and help center for the help center. Microsoft Power Tools was mentioned before (superuser.com/a/1668304/214658) May 12, 2022 at 8:33
1

On Windows 8, you can find "Keyboard" in the Control Panel. From there, open up the Microsoft Mouse and Keyboard Center. Under Keyboard, Basic settings, there's a list of special keys. Click on one of them, click on "View all commands". Below there, "Media commands" includes "Next Track", "Previous Track" and "Play/pause" among others.

Works well for me with Windows' own Music app.

I have a Microsoft keyboard, so I don't know if the Microsoft Mouse and Keyboard Center works the same with other keyboards.

1

I think WMP Keys might be a solution, but it only works with Windows Media Player.

WMP Keys What is it?

WMP Keys is global hot keys support addon for Windows Media Player

Installation

Close Windows Media Plyer
Download latest version of installer (wmpkeys.msi)
Double click wmpkeys.msi for installation
Launch Windows Media Player
Turn on plugin in Windows Media Plyer menu
0
1

I found one app which can do almost all of them in windows 7 and it works without any issues when your desktop is unlocked. Also it is pretty easy to use.

http://sourceforge.net/projects/hotkeyp/?source=typ_redirect.

Only drawback I found is it will not work when desktop is locked say I come back from sleep and the computer is locked and I have loud music playing. Multimedia keyboards can mute from there itself. But with this app you need to unlock first.

0

Cmd + Ctrl + Shift + F24 - shortcut for play/pause which I found with pynput module for python3.

It remains only to somehow emulate the pressing of these keys (I did it with the same pynput module)

You must log in to answer this question.

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