User Rating 0.0
Total Usage 0 times
Type any ASCII characters (0–127). Non-ASCII characters will be flagged.
Results
Enter ASCII text, decimal, or hex values above and click Convert.
Is this tool helpful?

Your feedback helps us improve.

About

Keyboard scan codes are the raw hardware-level identifiers sent by a keyboard controller to the host system. They differ fundamentally from ASCII values. A PS/2 keyboard using Set 1 (XT) sends 0x1E for the A key, while Set 2 (AT) sends 0x1C for the same physical key. USB HID keyboards use an entirely separate Usage ID table defined in the USB HID Usage Tables specification (Document v1.4). Confusing these code spaces is the most common source of bugs in firmware development, OS kernel input drivers, and bootloader keyboard handlers. This tool maps all 128 standard ASCII code points (0 - 127) to their corresponding PS/2 Set 1 Make code, PS/2 Set 2 Make code, and USB HID Usage ID. Extended codes (E0-prefixed) for keys like arrows or Insert are included where applicable.

Limitations: this mapping assumes a US QWERTY layout. Shifted characters (e.g., ! at 0x21) map to the base key’s scan code plus a Shift modifier flag. Non-printable control characters (0x00 - 0x1F) are mapped to their conventional key equivalents where a direct physical key exists (e.g., Tab, Enter, Escape, Backspace). Characters with no standard single-key mapping are marked accordingly.

ascii scan codes PS/2 USB HID keyboard converter key codes hardware

Formulas

The conversion is a direct lookup operation. No arithmetic formula is involved. Each ASCII code point c is used as an index into a mapping table T that returns a tuple of scan codes:

T(c) (S1, S2, U, m)

Where S1 = PS/2 Set 1 Make code, S2 = PS/2 Set 2 Make code, U = USB HID Usage ID, and m = modifier flag (Shift required: TRUE or FALSE). For uppercase letters and shifted symbols, the base key scan code is returned with m = TRUE, indicating the host must also send/register the Shift modifier (PS/2 Set 1: 0x2A, USB HID: 0xE1). The valid domain is c [0, 127] Z. Values outside this range produce no mapping.

Reference Data

ASCIIDecHexCharPS/2 Set 1 (Make)PS/2 Set 2 (Make)USB HIDKey Name
000x00NUL - - 0x00No Event
880x08BS0x0E0x660x2ABackspace
990x09TAB0x0F0x0D0x2BTab
13130x0DCR0x1C0x5A0x28Enter
27270x1BESC0x010x760x29Escape
32320x20SP0x390x290x2CSpace
48480x3000x0B0x450x270 Key
49490x3110x020x160x1E1 Key
50500x3220x030x1E0x1F2 Key
57570x3990x0A0x460x269 Key
65650x41A0x1E0x1C0x04A Key
66660x42B0x300x320x05B Key
67670x43C0x2E0x210x06C Key
87870x57W0x110x1D0x1AW Key
88880x58X0x2D0x220x1BX Key
89890x59Y0x150x350x1CY Key
90900x5AZ0x2C0x1A0x1DZ Key
97970x61a0x1E0x1C0x04A Key
1221220x7Az0x2C0x1A0x1DZ Key
1271270x7FDELE0 53E0 710x4CDelete

Frequently Asked Questions

PS/2 Set 1 (also called the XT set) was used by the original IBM PC XT keyboard. Set 2 (the AT set) is the default for PS/2 keyboards and is what most modern PS/2-compatible controllers actually transmit. The keyboard sends Set 2 codes on the wire, but the i8042 keyboard controller in the PC translates them to Set 1 before passing them to the CPU. This is why both sets are relevant: firmware working below the i8042 sees Set 2, while BIOS interrupt handlers and legacy OS drivers see Set 1.
Scan codes represent physical keys, not characters. The A key has PS/2 Set 1 Make code 0x1E regardless of case. The distinction between uppercase A (ASCII 65) and lowercase a (ASCII 97) is produced by combining the base key scan code with the Left Shift modifier (Set 1: 0x2A, USB HID: 0xE1). This tool flags such characters with a Shift indicator.
USB HID keyboards send a structured 8-byte report containing modifier flags and up to 6 simultaneous key Usage IDs. The Usage IDs are defined in the USB HID Usage Tables document (Keyboard/Keypad Page 0x07). They start at 0x04 for A and are sequential through Z. Unlike PS/2 scan codes, USB HID codes are layout-independent identifiers assigned by the USB-IF standard body, not by the keyboard hardware vendor.
Most ASCII control characters below 32 do not correspond to a dedicated physical key. Exceptions include Tab (0x09), Enter/CR (0x0D), Backspace (0x08), and Escape (0x1B). For the remaining control codes (e.g., SOH at 0x01, STX at 0x02), they are conventionally generated by holding Ctrl plus a letter key. This tool maps those to the corresponding letter key's scan code with a Ctrl modifier note.
Yes. Keys like Delete (ASCII 127) use extended PS/2 scan codes prefixed with 0xE0. For Set 1, Delete is E0 53; for Set 2, it is E0 71. The E0 prefix signals the keyboard controller that a two-byte scan code follows. This tool displays the full multi-byte code where applicable.
This tool assumes a US QWERTY layout (ANSI 104-key). On a German QWERTZ keyboard, pressing the physical key in the Z position still sends the same scan code (0x2C in Set 1), but the OS interprets it as Y. Scan codes are layout-agnostic at the hardware level. The mapping from scan code to character is performed by the OS keyboard driver using the active keymap.