Windows – How to edit keyboard registry settings for keys with 3-character scan-codes

keyboard shortcutswindows 7windows-registry

I have an Apple mini-USB keyboard I am using with Windows 7. My ultimate goal is to permanently remap the F12 key to be "Delete" so I can log in with Control+Alt+Delete (apple's keyboard only has backspace).

I have identified the keyboard scan codes for the keys I want to remap using AutoHotKey.

  • Delete – 153
  • F12 – 058

I have some experience with using the registry to remap keys such as caps to control, in this example:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

The registry code for Control as per this example is 3a,00 and its scancode is 03a. It seems you need to just remove the leading 0 in this case to remap the key.

How does this work when your scancode has a value on this leading digit? Am I suppose to just use 53 as the code?

Best Answer

The scancodes in the registry are in hexadecimal (base 16), and include two bytes. The first byte is sometimes used as an escape code (0xE0), as for the delete key:

Control's scancode is 58 or 0x003A
F12's scancode is 88 or 0x0058
Delete's scancode is escaped 83 or 0xE053

This results in the following registry edits to make this change (note you have to increase 02,00,00,00 to 03,00,00,00 to indicate the additional key):

53,e0,58,00    

What you want to do though, is get a utility called SharpKeys, which will provide a GUI interface to modify the registry key map. You can then compare and examine the registry key before and after to see how it changed the entry.

Related Question