Reassigning keys in Windows XP

I just got a brand new Microsoft Natural Ergonomic Keyboard 4000. The keyboard is great, but its left Alt key is a bit too small a bit too much to the side and very hard to reach with my thumb. Japanese keyboards have three extra keys around the space bar, keys that I never use, but keys that eat the width of other keys (just look at the English and Japanese variants and you'll see what I mean). I thus wanted to assign that never-used-key to behave the same as an ALT. It turned out to be easier than expected.

Detailed information about the process can be found in an article from Microsoft. It tells you that you need to add a binary key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\Scancode Map
. Its first eight bytes are all zeros, the next four bytes are the number of mappings (little-endian, so "02 00 00 00" for 2), and then four bytes for each mapping plus a mapping of all zeros ("00 00 00 00") as a terminator.

The number of mappings should include the terminator, so if only want to map one key you'd need to say that you have two mappings.

The mapping are written out by concatenating two short words (16-bit integers) in the order "from"-key, "to"-key. However, bear in mind that you have to reverse the bytes in the registry (little endian still). This can be confusing, because you byte-swap the concatenated word, and not the two short words that make it up. In other words the first byte you write would be the lower byte of the destination key, then the higher byte of the destination, lower byte of the key being mapped and finally the higher byte of the key being mapped.

So, to make your caps lock key behave as control, you would write the following





ValueBytesExplanation
00 00 00 00 00 00 00 000-8Header and flags, all zero for now
02 00 00 009-12Number of mappings, 2 (caps -> control and null)
1d 00 3a 0013-16 Caps -> Control. 0x003a is Caps, 0x001d is Control. 0x003a001d --> 1d 00 3a 00
00 00 00 0017-20Terminator mapping


The codes for the keys are available in a related article from Microsoft. You can download a doc or pdf file that has all possible keys (including the weird keys on Japanese, Korean and so-on keyboards).

And here is what I used to swap control and caps lock and map the three Japanese keys to Alt:
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,\\
06,00,00,00,\\
3a,00,1d,00,\\
1d,00,3a,00,\\
38,e0,79,00,\\
38,e0,70,00,\\
38,00,7b,00,\\
00,00,00,00


Here is also a Caps Lock to Control
registry file.

Comments

Popular posts from this blog

ADSL Router Model CT-5367 user and pass (VIVACOM)

Installing Gentoo with full disk encryption

FreeIPA cluster with containers