Today I tried to remap some keyboard media keys to more useful functions and failed to do so.

enter image description here

The problem

  • The manufacturer doesn't provide a utility to bind and execute custom commands.
    My previous keyboard from Logitech had such options in their SetPoint software
  • The key codes (or scancode) were not recognized by most programs which I used to catch the underlying key codes.

    For example the otherwise excellent tool SharpKeys has a catch mode where it tells you what key you've just pressed. It took me some time to realize that it told me a wrong key code During my tests I pressed the "star button" in the top right and SharpKeys tells me that this is the key "D" with it's key code 00_20. But the correct key code would be 00_181

    Another try was this AutoHotKey script which also failed to recognize my unusual media keys

The task

  • Find the correct key codes even for unusual media buttons
  • Remap all media keys without any installation of an additional tool or program. A registry tweak, the use of an already installed driver or a small portable app is acceptable

2 Answers 2


This is a generic way to remap any keyboard buttons. Even weird ones

  1. Use KeyCodes (portable,415 KB) to catch the key code. Download, extract and start KeyCodes3.exe. Press your mysterious button and you'll see the key code as decimal number

    enter image description here

    An alternative way was this AHK script which uses a keyboard hook and "KeyHistory"

    while !(getKeyState("F1", "T"))

    enter image description here

  2. Convert the number from decimal to hexadecimal: 171 » AB

  3. Use the portable version of AutoHotKey to remap the button.
    Download and extract the .zip version of your choice somewhere. No installation needed.
    Create a new text file and paste

    #NoEnv, #Persistent, #SingleInstance
    vkB5::return                ;music node button  181 » B5   do nothing
    vkAC::return                ;home button        172 » AC   do nothing
    vkAA::return                ;search button      170 » AA   do nothing
    vkAB::Run, c:\myapp.exe     ;star button        171 » AB   execute tool
    vkB4::Send {Volume_Mute}    ;mail button        180 » B4   mute/unmute
    • vk stands for virtual key code followed by your hexadezimal key code you want to remap
    • :: is the remap operator. Left is the trigger, right of it is your new button or action
    • Send {<my_new_key>} could be any key from this list.
      Alternatively you could execute a custom path with the Run command.
      Or if you want to to execute a media button again, use {vkAB} as action
  4. Create a new shortcut in your autostart folder to start your AHK script on each boot. For example

    "D:\Tools\AutoHotKey\AutoHotkey.exe" "D:\Tools\AutoHotKey\RemapKeys.ahk"

After a reboot or manual AHK script start, all buttons are remapped

  • Everything worked except mapping a mute key to run a command (e.g. vkAD::Run, c:\myapp.exe didn't work for me), I had to remap it twice to make it work, something like vkAD::F21 and then another mapping: F21::Run, c:\myapp.exe
    – BornToCode
    Aug 2, 2016 at 11:32
  • My antivirus (ESET EndpointAntivirus) flagged the executable download as a threat.
    – PhilMacKay
    Mar 6, 2017 at 16:19
  • Looks like the KeyCodes download is dead :( Jul 27, 2020 at 23:00
  • @JoelCoehoorn yeah, looks like. But the source code is still available. Maybe someone can build an executable? I have no idea what programming language was used there
    – nixda
    Jul 28, 2020 at 12:48
  • For Step 1's alternative approach to get the codes using AutoHotKey, the instructions at the first answer here have some additional details which may be useful for newer users. Dec 29, 2020 at 14:20

In short: you can find multimedia keys mapping in the following registry key: "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey"

E.g. the mail key usually launches the default mail app.

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\15\RegisteredApp = "Mail"

If you want to replace this to open Notepad,

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\15\ShellExecute = "notepad.exe"

(Or change HKLM if you want to modify for all users etc)

RegisteredApp means the app registered for that function will be called. (Like Mail above)

Association Means the app associated with a particular file type will be opened. For e.g. the Media key is registered by default to .cda, meaning the default app used for playing music CDs will be opened on pressing that key.

ShellExecute opens a particular program to be run.

For more details read this article

  • 2
    Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.
    – DavidPostill
    Jun 2, 2016 at 8:05
  • I have been able to remap "Calculator" but not "Media PLay/Pause".
    – PhilMacKay
    Mar 6, 2017 at 16:20
  • Thank you so much! This allowed me to select a media player outside of Windows 10 store without AutoHotKey black magic. May 1 at 18:11

You must log in to answer this question.

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