This keyboard has a strange and painful mapping of the Home,End,PgUp,PgDn keys. Luckily for the keys, we can just pop those suckers off and move them to their “proper” locations. Then with a quick registry entry, set the correct key response to the new locations.
This post documents a registry-based keyboard remap that swaps the physical Page Up and End keys system-wide, using Windows’ built-in Scancode Map mechanism.
Overview
Windows reads a binary value at boot from:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
named Scancode Map, which lets the keyboard driver remap any physical key to send a different scan code before it ever reaches an application. A reboot is required any time this value is changed, since the driver only reads it once at startup.
The value used to swap Pageup with End[3]
hex:00,00,00,00,00,00,00,00,03,00,00,00,49,e0,4f,e0,4f,e0,49,e0,00,00,00,00
Byte-by-byte breakdown
The value is a sequence of 4-byte DWORD entries. Each byte pair below is written little-endian (low byte first).
| Bytes | Purpose | Value |
|---|---|---|
00,00,00,00 | Header (version field) | Always 0 |
00,00,00,00 | Header (flags field) | Always 0 |
03,00,00,00 | Entry count | 3 — the total number of 4-byte mapping entries that follow, including the required null terminator |
49,e0, 4f,e0 | Mapping entry 1 | Target scan code e0,49 (Page Up) ← Source scan code e0,4f (End) — i.e. pressing End sends Page Up |
4f,e0, 49,e0 | Mapping entry 2 | Target scan code e0,4f (End) ← Source scan code e0,49 (Page Up) — i.e. pressing Page Up sends End |
00,00,00,00 | Null terminator | Marks the end of the mapping list; always required as the final entry |
Note on entry format: each mapping entry is two 2-byte scan codes — target first, then source — read low-byte/high-byte (little-endian). The e0 prefix marks an “extended” scan code, used for keys that have a duplicate elsewhere on the keyboard (e.g. Page Up/Down, End, Home, arrow keys, right-side Ctrl/Alt).
Setting it via Command Prompt
Requires an elevated (Run as administrator) Command Prompt, since the key lives under HKEY_LOCAL_MACHINE. A reboot is required afterward for the change to take effect.
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map" /t REG_BINARY /d 00000000000000000300000049e04fe04fe049e000000000 /f
Note: reg add for a REG_BINARY value takes the hex bytes as one continuous string with no commas or spaces — different from the comma-separated .reg file syntax shown above.
Removing it
Also requires an elevated Command Prompt, and a reboot afterward.
reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map" /f
Verifying the current value
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map"
Leave a Reply