Today I tried to remap some keyboard media keys to more useful functions and failed to do so.
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 code00_20
. But the correct key code would be00_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
Best Answer
This is a generic way to remap any keyboard buttons. Even weird ones
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
An alternative way was this AHK script which uses a keyboard hook and "KeyHistory"
Convert the number from decimal to hexadecimal:
171
»AB
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
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 actionSend {<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 actionCreate a new shortcut in your autostart folder to start your AHK script on each boot. For example
After a reboot or manual AHK script start, all buttons are remapped