My previous system was a Linux-box. I made some adjustments to my keyboard in order to make it “better”. Since I use Vim a lot (apologies to Emacs-fans), the escape-key is doing overtime. On a normal keyboard however, the escape-key is located at the top left. Other keys are very near the main keyboard, but are hardly used. I almost never use the CapsLock key at all. So I switched both keys around, giving the CapsLock key the escape-function and the other way around.

Under Linux, you can remap keys using xmodmap. It seems that Windows has a similar feature, although much less documented. Here is a short summary of this article.

Windows has two levels to change the keyboard. The system-level is configured through the [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] registry key; the user-level one is located at [HKEY_CURRENT_USER\Keyboard Layout].

By adding (or editing) the “Scancode Map” value of type Binary Value, one can control the mapping of scancodes. Since we are at a scancode level, this operation is preformed very early in the stack (VMware only gets to see the scancodes after this mapping).

The content of the value is a bit of a mistery:

  • It must start with 8 bytes of 0x00
  • The next byte indicates how many mappings are following, PLUS 1
  • The mappings themselves, 4 bytes each. First 2 bytes indicate the new scancode to map to; the next 2 bytes indicate the original scancode to map from.
  • It must end with 4 bytes of 0x00

For my examle the binary value ended up being (line breaks are for clarity only):

00 00 00 00 00 00 00 00
03
3a 00 01 00
01 00 3a 00
00 00 00 00