Keyboard Layout Assistant

Кeyboard Layout Аssistant is an application used to assist in the creation of keyboard layouts for different systems, remapping keyboard keys, and the development of software applications handling keyboard events.

The application presents a standard US physical keyboard layout. For other layouts, please use test applications for Windows and Web browsers.

Layers

The key data is shown in nine separate layers representing different platforms, one layer at a time.

Labels

This layer is informal. It roughly corresponds to the labels written on the key of a standard US keyboard, but provides a bit more information.

Point to the key to see the details. Some keys have different names for different keyboard models, notably, the Windows Logo key (also known as “Super” or “Meta”) and the Context Menu key.

Scan Codes, Key Down

Low-level hardware scan codes are sent by the keyboard to the computer when a user presses a key. Please see Scan Codes for more information.

Scan Codes, Key Up

Low-level hardware scan codes sent by the keyboard to the computer when a user releases a key. Please see Scan Codes for more information.

Linux XKB Key Codes

X Keyboard Extension (XKB) is a part of X_Window_System.

It can be used, in particular, for the creation of keyboard layouts for Linux.

On the keyboard, the key names are shown without angular brackets. Point to the key to see the details, or click it to see how the key names are presented in the files.

Windows Virtual Keys

Windows virtual keys are dispatched to the Windows application handling the event WM_KEYDOWN and WM_KEYDUP messages. The virtual-key code is passed as the parameter wParam.

See also: Virtual-Key Codes.

The virtual key codes do not depend on the culture or keyboard layout. However, the virtual key codes of the numpad depend on the state of the Num Lock key.

.NET System.Windows.Forms

The enumeration members of the type System.Windows.Forms.Keys.

See .NET Keyboard Events.

.NET WPF

System.Windows.Input.Key.

See .NET Keyboard Events.

JavaScript Key

KeyboardEvent.key property values.

This is the only case when the key data depends on the software keyboard layout. To identify the keys independently from the layout, KeyboardEvent.code can be used.

See also Web Browser Keyboard Events.

JavaScript Code

KeyboardEvent.code property values.

See also Web Browser Keyboard Events.

Notes

Scan Codes

Keyboards create a hardware interrupt and send sequences of low-level hardware scan codes, typically 1 or 2 bytes, or more, in some special cases.

On PC, this is IRQ 1, int 1, and the data can be read from the port 0x60, and the port 0x64 is used for the status information. The application must send an End-Of-Interrupt (EOI) command to the port 0x20, so the CPU knows it can receive future hardware interrupts.

The scan codes sent when a user presses the key and releases the key are different, so the scan codes are presented in two separate layers.

On Windows, the scan codes can be obtained by handling the message WM_INPUT and using raw input. Please see the test application for Windows

Scan codes can be used on Windows for remapping keyboard keys. The remapping table is stored in the system Registry at the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout under the name Scancode Map. The table is a block of 4-byte sequences of the type REG_BINARY representing the pairs of the output and input scan codes.

The scan code remapping is automated safely with the application Keyboard Deconvolutor.

.NET Keyboard Events

.NET Keyboard Events depend on the presentation framework used. There are two different keyboard systems for System.Windows.Forms and WPF.

The enumeration types System.Windows.Forms.Keys and the WPF System.Windows.Input.Key are pretty similar but different. Importantly, these two enumeration types have different underlying numeric values. System.Windows.Forms.Keys is modeled after the Windows Virtual Keys.

The names of the enumeration members are also different. It looks like some System.Windows.Forms.Keys member names have been corrected in WPF.

Also, the order of the alias enumeration members, that is, the enumeration members with the identical underlying numeric values, is different:

System.Windows.Forms:

Return ≡ Enter ≡ 13
Capital ≡ CapsLock ≡ 20
Prior ≡ PageUp ≡ 33
Next ≡ PageDown ≡ 34
Snapshot ≡ PrintScreen ≡ 44
OemSemicolon ≡ Oem1 ≡ 186
OemQuestion ≡ Oem2 ≡ 191
Oem3 ≡ Oemtilde ≡ 192
OemOpenBrackets ≡ Oem4 ≡ 219
OemPipe ≡ Oem5 ≡ 220
OemCloseBrackets ≡ Oem6 ≡ 221
Oem7 ≡ OemQuotes ≡ 222
Oem102 ≡ OemBackslash ≡ 226
WPF:

Return ≡ Enter ≡ 6
Capital ≡ CapsLock ≡ 8
Prior ≡ PageUp ≡ 19
Next ≡ PageDown ≡ 20
Snapshot ≡ PrintScreen ≡ 30
Oem1 ≡ OemSemicolon ≡ 140
Oem2 ≡ OemQuestion ≡ 145
Oem3 ≡ OemTilde ≡ 146
Oem4 ≡ OemOpenBrackets ≡ 149
Oem5 ≡ OemPipe ≡ 150
Oem6 ≡ OemCloseBrackets ≡ 151   
Oem7 ≡ OemQuotes ≡ 152
Oem102 ≡ OemBackslash ≡ 154

The tables shown above are generated with the test application “Duplicates”, please see the .NET solution.

To minimize the confusion, the keyboard keys are marked with the enumeration member names that come first. This way, the keyboard shows the same names reported by the test applications. Both equivalent names are shown in the detailed view when the user points to a key.

Web Browser Keyboard Events

In Web browsers, the KeyboardEvent object is passed to the handlers of the events keydown, keyup, or obsolete keypress.

Two properties, not considering the obsolete ones, can be used to identify keys: KeyboardEvent.key and KeyboardEvent.code.

Please see the test application for Web browsers for more information.

Any Questions?

Please ask any questions using the GitHub Discussions related to this repository.