ASCII Keyboard Reference
Every key on a standard US keyboard maps to one or two ASCII values depending on whether Shift is held. Pressing the A key sends ASCII 97 (lowercase a). Hold Shift and it sends 65 (uppercase A). The difference between any uppercase and lowercase letter is always exactly 32, a single bit flip at position 5 in the binary representation. This was a deliberate hardware optimization from the 1963 ASA committee.
The keyboard itself does not generate ASCII codes. It sends scancodes that identify the physical key position. Scancode 0x1E fires whether your layout is QWERTY, AZERTY, or Dvorak. The operating system's keyboard driver translates scancodes into character codes based on the active layout and modifier state.
The Ctrl key works by clearing bits 5 and 6 of the character code, mapping letters tocontrol characters 0 through 31. Ctrl+A produces SOH (1), Ctrl+Z produces SUB (26). This bitmask trick is why the 26 Ctrl+letter combinations map directly to the first 26 control characters.
Letter Keys (A-Z)
Each letter key produces two ASCII values. Lowercase occupies positions 97-122, uppercase 65-90. Toggle case by adding or subtracting 32. In binary, bit 5 (value 32) is the only difference betweenA (1000001) anda (1100001).
| Key | Upper | Dec | Hex | Lower | Dec | Hex |
|---|---|---|---|---|---|---|
| A / a | A | 65 | 0x41 | a | 97 | 0x61 |
| B / b | B | 66 | 0x42 | b | 98 | 0x62 |
| C / c | C | 67 | 0x43 | c | 99 | 0x63 |
| D / d | D | 68 | 0x44 | d | 100 | 0x64 |
| E / e | E | 69 | 0x45 | e | 101 | 0x65 |
| F / f | F | 70 | 0x46 | f | 102 | 0x66 |
| G / g | G | 71 | 0x47 | g | 103 | 0x67 |
| H / h | H | 72 | 0x48 | h | 104 | 0x68 |
| I / i | I | 73 | 0x49 | i | 105 | 0x69 |
| J / j | J | 74 | 0x4A | j | 106 | 0x6A |
| K / k | K | 75 | 0x4B | k | 107 | 0x6B |
| L / l | L | 76 | 0x4C | l | 108 | 0x6C |
| M / m | M | 77 | 0x4D | m | 109 | 0x6D |
| N / n | N | 78 | 0x4E | n | 110 | 0x6E |
| O / o | O | 79 | 0x4F | o | 111 | 0x6F |
| P / p | P | 80 | 0x50 | p | 112 | 0x70 |
| Q / q | Q | 81 | 0x51 | q | 113 | 0x71 |
| R / r | R | 82 | 0x52 | r | 114 | 0x72 |
| S / s | S | 83 | 0x53 | s | 115 | 0x73 |
| T / t | T | 84 | 0x54 | t | 116 | 0x74 |
| U / u | U | 85 | 0x55 | u | 117 | 0x75 |
| V / v | V | 86 | 0x56 | v | 118 | 0x76 |
| W / w | W | 87 | 0x57 | w | 119 | 0x77 |
| X / x | X | 88 | 0x58 | x | 120 | 0x78 |
| Y / y | Y | 89 | 0x59 | y | 121 | 0x79 |
| Z / z | Z | 90 | 0x5A | z | 122 | 0x7A |
Digit Keys and Their Shifted Symbols
Digits 0-9 occupy ASCII positions 48-57. Subtract 48 from any digit's ASCII code to get its numeric value. Each digit key also produces a symbol when Shift is held. This mapping is specific to the US QWERTY layout. UK keyboards put the double quote on Shift+2 instead of @.
Punctuation and Symbol Keys
The remaining punctuation keyseach produce two ASCII characters. Brackets, braces, backslash, semicolon, quotes, and the comma/period/slash cluster all follow the same normal/shifted pattern.
Whitespace Keys
Three keyboard keys produce whitespace characters. Space (32)is the only one with a visible gap on screen. Tab (9) advances to the next tab stop. Enter produces either CR, LF, or CR+LF depending on the platform and terminal mode.
| Key | ASCII Name | Dec | Hex |
|---|---|---|---|
| Space | SP (Space) | 32 | 0x20 |
| Tab | HT (Horizontal Tab) | 9 | 0x09 |
| Enter | CR (Carriage Return) | 13 | 0x0D |
| Enter (Unix) | LF (Line Feed) | 10 | 0x0A |
Ctrl Key Combinations
Holding Ctrl while pressing a key clears bits 5 and 6 of the ASCII value. This maps Ctrl+A through Ctrl+Z to control characters 1 through 26. Several of these have modern terminal functions: Ctrl+C sends SIGINT (interrupt), Ctrl+D sends EOF, Ctrl+Z sends SIGTSTP (suspend). The rest are mostly vestigial teletype codes.
| Combination | Dec | Hex | Name | Function |
|---|---|---|---|---|
| Ctrl+@ | 0 | 0x00 | NUL | Null character, C string terminator |
| Ctrl+A | 1 | 0x01 | SOH | Start of Heading |
| Ctrl+B | 2 | 0x02 | STX | Start of Text |
| Ctrl+C | 3 | 0x03 | ETX | End of Text / terminal interrupt (SIGINT) |
| Ctrl+D | 4 | 0x04 | EOT | End of Transmission / Unix EOF |
| Ctrl+E | 5 | 0x05 | ENQ | Enquiry |
| Ctrl+F | 6 | 0x06 | ACK | Acknowledge |
| Ctrl+G | 7 | 0x07 | BEL | Bell / terminal beep (\a) |
| Ctrl+H | 8 | 0x08 | BS | Backspace |
| Ctrl+I | 9 | 0x09 | HT | Horizontal Tab (same as Tab key) |
| Ctrl+J | 10 | 0x0A | LF | Line Feed / Unix newline |
| Ctrl+K | 11 | 0x0B | VT | Vertical Tab |
| Ctrl+L | 12 | 0x0C | FF | Form Feed / clear terminal screen |
| Ctrl+M | 13 | 0x0D | CR | Carriage Return (same as Enter) |
| Ctrl+N | 14 | 0x0E | SO | Shift Out |
| Ctrl+O | 15 | 0x0F | SI | Shift In |
| Ctrl+P | 16 | 0x10 | DLE | Data Link Escape |
| Ctrl+Q | 17 | 0x11 | DC1 | XON / resume serial transmission |
| Ctrl+R | 18 | 0x12 | DC2 | Device Control 2 |
| Ctrl+S | 19 | 0x13 | DC3 | XOFF / pause serial transmission |
| Ctrl+T | 20 | 0x14 | DC4 | Device Control 4 |
| Ctrl+U | 21 | 0x15 | NAK | Negative Acknowledge |
| Ctrl+V | 22 | 0x16 | SYN | Synchronous Idle / terminal literal next |
| Ctrl+W | 23 | 0x17 | ETB | End of Transmission Block |
| Ctrl+X | 24 | 0x18 | CAN | Cancel |
| Ctrl+Y | 25 | 0x19 | EM | End of Medium |
| Ctrl+Z | 26 | 0x1A | SUB | Substitute / Unix suspend (SIGTSTP) |
| Ctrl+[ | 27 | 0x1B | ESC | Escape (same as Esc key) |
| Ctrl+\ | 28 | 0x1C | FS | File Separator / terminal quit (SIGQUIT) |
| Ctrl+] | 29 | 0x1D | GS | Group Separator / telnet escape |
| Ctrl+^ | 30 | 0x1E | RS | Record Separator |
| Ctrl+_ | 31 | 0x1F | US | Unit Separator |
Special Keys
These keys produce ASCII control characters but have dedicated physical keys rather than requiring the Ctrl modifier. Backspace and Delete are frequently confused because terminal emulators map them inconsistently. Check your terminal's configuration if pressing Backspace produces ^? instead of erasing the character.
Keys That Send Escape Sequences
Arrow keys, function keys, Home, End, and other navigation keys have no single ASCII code. Instead, they send multi-byte ANSI escape sequences based on the VT100 terminal standard (DEC, 1978). Every sequence starts with ESC (27), followed by one or more ASCII bytes that identify the key.
| Key | Sequence |
|---|---|
| Up Arrow | ESC [ A |
| Down Arrow | ESC [ B |
| Right Arrow | ESC [ C |
| Left Arrow | ESC [ D |
| Home | ESC [ H |
| End | ESC [ F |
| Insert | ESC [ 2 ~ |
| Page Up | ESC [ 5 ~ |
| Page Down | ESC [ 6 ~ |
| F1 | ESC O P |
| F2 | ESC O Q |
| F3 | ESC O R |
| F4 | ESC O S |
| F5 | ESC [ 1 5 ~ |
| F12 | ESC [ 2 4 ~ |
Platform Differences
The same physical key can produce different ASCII codes depending on the operating system and terminal configuration. These differences cause real bugs, especially with line endings and the Backspace/Delete confusion.
| Key | Windows | macOS | Linux |
|---|---|---|---|
| Enter | CR+LF (13, 10) | LF (10) | LF (10) |
| Backspace | BS (8) | DEL (127) | DEL (127) or BS (8) |
| Delete | ESC [ 3 ~ | ESC [ 3 ~ | ESC [ 3 ~ |
| Ctrl+Z | SUB (26) / EOF marker | SUB (26) / SIGTSTP | SUB (26) / SIGTSTP |
| Special chars | ALT codes via numpad | Option key combinations | Compose key sequences |
On Windows, ALT codes let you type any character from the active code page by holding ALT and typing the decimal value on the numeric keypad. ALT+65 produces A, ALT+130 produces the accented e fromCode Page 437. Adding a leading zero (ALT+0233) uses the Windows-1252code page instead.
Keys With No ASCII Representation
Several keyboard keys exist entirely outside the ASCII character set. They produce hardware scancodes or OS-level keycodes but never generate an ASCII byte. Applications that read raw ASCII input (like serial terminal programs) cannot detect these keys at all.
| Key | What It Sends | Used By |
|---|---|---|
| Windows / Super | OS-level keycode only | Start menu, window management shortcuts |
| Command (Mac) | OS-level keycode only | Application shortcuts (Cmd+C, Cmd+V) |
| Alt / Option | Modifier flag, no ASCII output alone | Menu access (Windows), special chars (Mac) |
| Caps Lock | Scancode toggle, no ASCII output | Shifts letter case state persistently |
| Num Lock | Scancode toggle, no ASCII output | Switches numpad between numbers and navigation |
| Scroll Lock | Scancode toggle, no ASCII output | Legacy terminal scrollback, largely unused |
| Print Screen | OS-level event only | Screenshot capture |
| Pause / Break | Scancode only (E1 1D 45) | Debugging, legacy DOS pause |
| Volume / Media keys | HID usage codes via USB | OS media controls, not visible to applications |