Lamer87 / Keyboard_ScanCodes_for_remapping

Simple guide to remap / rebind keyboard keys with scancodes in regedit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a simple guide for remapping (rebinding) keyboard keys

whitout using a tool, just the system registry (in hexadecimal).

v1.5 - For ISO, ANSI, ABNT and JIS layouts.

  • 💾 You can download the package (readme, example and remover) here 💾
    (or just click on "Code" then "Download ZIP").

    • The EXAMPLE file (Rebind.reg) it's meant to be edited by you.
      This file is ALREADY modified and will add the necessary "hex" value to the registry,
      so before applying it you have to EDIT IT properly.

    • If you want to get rid of the remapping, use the file "remover.reg",
      it can be even used to create just the empty hex value.

    • Every time you apply the values, you must AT LEAST logout and login (or restart), for the changes to take effect.


  • 📜 How to manually create the value in the registry:

    • 1- Open "C:\Windows\regedit.exe"
    • 2- Go to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout" (not \Keyboard LayoutS)
    • 3- Create a new "binary value" here, named "Scancode Map" (without quotes).
  • ✔️ What goes inside the binary value is described below in the regedit file format, so you don't have to manually enter values via regedit.exe, but just edit Rebind.reg with notepad, then exec it.


⚠️ 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,3A,00,5D,E0,00,00,00,00

What means an entire regedit code:

00,00,00,00, 00,00,00,00, 02,00,00,00, 3A,00,5D,E0, 00,00,00,00
1st 8 bits 2nd 8 bits 3rd 8 bits 4th 8 bits 5th 8 bits
Version Flag Number of rebinds +1! Rebind n1 Final bits (null)

Each PAIR of zeroes is separated by a comma (,) except for the last pair which ends without.

Version: always 8 zeroes.

Flag: always 8 zeroes.

Rebind n1:
3A,00, = 1st part: it's the keycode of the remapping.
5D,E0, = 2nd part: keycode of the button you actually press.

Number of rebinds:
only the first 2 bits count as a number (examples: 02 if 2, 05 if 5, 13 if 13),
the value must be made up of the number of rebinds (that are 8 bits for each one),
plus one for the final 8 bits.
For example, if we want to rebind 4 keys, the value number of rebinds will be 05,00,00,00,
if the rebinds are 12 the value will be 13,00,00,00,

Final bits: always 8 zeroes.

What means a single scancode like "5D,EO":

5D: this first couple it's the scancode of the key.
E0: this second couple can be 00 or E0; some keys have the same first couple, changing only this.

📜 This is just an explanation of a reg with 3 rebinds (do not use in a reg file!):

hex:00,00,00,00,00,00,00,00,04,00,00,00,3A,00,5D,E0,3E,00,46,00,3F,00,45,E0,00,00,00,00
   |  version  |   flag    |reb. number| 1st rebind| 2nd rebind| 3rd rebind| null bits |
                                       | these 4 lines count for the number of rebinds |

📜 Same as above with a vertical view (do not use in a reg file!)

hex:
00,00,00,00,  =  version
00,00,00,00,  =  flag
04,00,00,00,  =  number of rebinds +1
3A,00,5D,E0,  =  rebind n1   --\
3E,00,46,00,  =  rebind n2      \ these 4 lines count towards the
3F,00,45,E0,  =  rebind n3      / total number of rebinds (even final bits)
00,00,00,00   =  final bits  --/


📌 Key ScanCode table:

the secondary code is always "00" when there are only 2 digits in "Code",

otherwise it's specified !

Code Key (+ shift) ITA layout (ISO) Other
1st Row: ————————— ————————— —————————
01 Esc
3B F1
3C F2
3D F3
3E F4
3F F5
40 F6
41 F7
42 F8
43 F9
44 F10
57 F11
58 F12
2nd Row: ————————— ————————— —————————
29 ` ~ \ |
02 1 !
03 2 @ "
04 3 # £
05 4 $
06 5 %
07 6 ^ &
08 7 & /
09 8 * (
0A 9 ( )
0B 0 ) =
0C - _ ' ?
0D = + ì ^
7D \ | (JIS note²)
0E Backspace
3rd Row: ————————— ————————— —————————
0F Tab
10 Q
11 W
12 E
13 R
14 T
15 Y
16 U
17 I
18 O
19 P
1A [ { è é [
1B ] } + * ]
2B \ | (ANSI) 4th row "ù §" (ISO)
1C Enter (ISO) Invio
4th Row: ————————— ————————— —————————
3A CapsLock Bloc Maiusc
1E A
1F S
20 D
21 F
22 G
23 H
24 J
25 K
26 L
27 ; : ò ç @
28 ' " à ° #
2B 3th row "\ |" (ANSI) ù § (ISO)
1C Enter (All layouts) Invio
5th Row: ————————— ————————— —————————
2A LeftShift Maiusc sx
56 \ | (ISO) < >
2C Z
2D X
2E C
2F V
30 B
31 N
32 M
33 , ;
34 . :
35 / ? - _
73 / _ (ABNT; JIS note²)
36 RightShift Maiusc dx
6th Row: ————————— ————————— —————————
1D LeftCtrl
5B-E0 LeftWin
38 LeftAlt
7B jap (JIS note²)
39 Space
79 jap (JIS note²)
70 jap (JIS note²)
38-E0 RightAlt
5C-E0 RightWin
5D-E0 Menu
1D-E0 RightCtrl
Middle: ————————— ————————— —————————
37-E0 PrintScreen Stamp
46 ScrollLock Bloc scorr
45-E1-1D Pause [see note¹❗] Pausa [vedi note¹❗]
52-E0 Insert
53-E0 Delete Canc
47-E0 Home Inizio
4F-E0 End Fine
49-E0 PageUp
51-E0 PageDown
48-E0 Up
50-E0 Down
4B-E0 Left
4D-E0 Right
KeyPad: ————————— ————————— —————————
45 NumLock
35-E0 /
37 *
4A -
4E +
7E . (ABNT)
1C-E0 Enter
53 . / Del
52 0 / Ins
4F 1 / End
50 2 / Down
51 3 / PgDn
4B 4 / Left
4C 5
4D 6 / Right
47 7 / Home
48 8 / Up
49 9 / PgUp

CLICK HERE to show other keys that need to be tested. They may not work properly, especially in games.

Code Function
64 F13 / PrintScreen
65 F14 / ScrollLock
66 F15 / Pause
67 F16
68 F17
69 F18
6A F19
6B F20
6C F21
6D F22
6E F23
6F F24
5E-E0 Power
5F-E0 Sleep
63-E0 Wake
21-E0 Calculator
6C-E0 Mail
6D-E0 Media Select
11-E0 Messenger
6B-E0 My Computer
22-E0 Play/Pause
24-E0 Stop
19-E0 Next track
10-E0 Prev track
30-E0 Volume up
2E-E0 Volume down
20-E0 Mute

  • Note 1: "Pause" button can't be used/remapped because it's a multiple bits hex (need a tool like AutoHotKey).
  • Note 2: other keys (like JIS) may not work if you haven't set the correct language (japanase) to Windows.


📌 Graph of a complete layout (all together)

Secondary code: only 2 digits = "00", instead "E0" is specified.
Orange = layout variations.

Source: kbdlayout.info


🕹️ Tools

  • ⌨️ SHOW SCANCODES: a good tool to show scancodes of your keyboard is Keyboard Key Info,
    it shows what keycode are you pressing on the keyboard (1st part only).
    Example: "ScanCode=0x4F" where the keycode 1st part is "4F" but you don't know if the second part is 00 or E0,
    so just take a look at the table when needed.

  • ⌨️ EASY REMAPPING: another good tool is SharpKeys tool,
    uses the same method as this guide (regedit hex) but with a graphical interface.
    Remember! do NOT use the "Pause" button: the tool recognizes it but then it doesn't work either way
    (when "Pause" is used to press another key, or when another key is used to press "Pause").


💡 If you want to contribute, you can report any error in Issues or new keys in Discussions.

Changelog (click to show):

  • v1.0 first guide/list.
  • v1.1 added JIS layout key codes.
  • v1.2 added other functions key codes.
  • v1.3 Corrected button "Pause"; can't be used or remapped without a tool like AutoHotKey.
  • v1.4 added other functions key codes.
  • v1.5 added ABNT layout key codes.


About

Simple guide to remap / rebind keyboard keys with scancodes in regedit