Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
also, depending if you use the Windows Sidebar, there may be a Gadget availible for media player controls... –  tombull89 May 4 '11 at 11:21
    
o/s ? for linxu gconf can do it. –  Sirex May 4 '11 at 13:41
    
related: superuser.com/questions/278369/… –  Jeff Atwood May 5 '11 at 5:07
add comment

7 Answers

up vote 3 down vote accepted

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

share|improve this answer
add comment

Just like tombull89 I am going to suggest AutoHotkey (I used it for the first time like 5 years ago IIRC) and mention some other things.

Windows

AutoHotkey

http://www.autohotkey.com/

What is AutoHotkey you can read at its homepage or in tombull89's answer quoting it, so I won't repeat it. Actually nowadays it's better to use AutoHotkey_L, a custom build of AutoHotkey maintained by Lexikos, which has 64-bit support and native Unicode support. Installer

For a newcomer this is still not helpful, I am aware of this. To have a grasp of AH it's good to skim at least Quick-start Tutorial and later browse rest of Documentation if needed.

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 MessageBox 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 AutoHotkeys' 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):

<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 is not supported on Windows 95/98/Me (AutoHotkey can do some limited Win9x remapping).
  • 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.

Linux

TBD (sorry, don't have time now, I'll promise I fix it some time later)

share|improve this answer
2  
Very nice @przemoc, perhaps you want to elaborate on this a little bit more in a blog post for the Super User blog? –  Ivo Flipse May 4 '11 at 12:47
    
@IvoFlipse I can someday, but if there are any deadlines, I quit immediately. :) –  przemoc May 4 '11 at 18:20
    
The deadline is whenever you're ready :-) –  Ivo Flipse May 4 '11 at 18:48
    
@ivo did this ever get blogged? –  Jeff Atwood Sep 25 '12 at 9:11
    
@Jeff: No. I'm really sorry, but somehow I have never managed to turn it into more elaborate article. And there is still a blatant lack of Linux-related discussion in my answer. –  przemoc Sep 25 '12 at 9:24
add comment

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.

share|improve this answer
    
also, slighty going off, does your media player come with keyboard shortcuts? i.e. iTunes has a large shortcut list. –  tombull89 May 4 '11 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 '11 at 10:41
2  
It would be helpful if you actually explained how to do so ;-) –  Ivo Flipse May 4 '11 at 10:49
    
@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 '11 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 '11 at 12:42
show 1 more comment

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
share|improve this answer
add comment

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).

share|improve this answer
add comment

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 KeyRemap4MacBook

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.