ASCII to Keycodes Converter
Convert ASCII characters to JavaScript keycodes, decimal, hex, and HTML entities. Full 0-127 ASCII table with live keyboard capture.
Press any key on your keyboard
| Dec | Hex | Oct | Bin | Char | HTML | Description | keyCode |
|---|
About
JavaScript's KeyboardEvent.keyCode property was deprecated in favor of KeyboardEvent.key and KeyboardEvent.code, yet legacy codebases and interview questions still reference numeric keycodes daily. Confusing charCode (from charCodeAt) with keyCode (from KeyboardEvent) causes silent bugs in form validation, game input handlers, and accessibility layers. This tool maps every ASCII character in the range 0 - 127 to its decimal code point, hexadecimal value, and HTML entity. It also captures live keypresses so you can verify the actual keyCode, key, and code values your browser emits.
Note: keyCode values for printable characters often match the uppercase ASCII code point (e.g., both 65 for "a" and "A"), while charCodeAt distinguishes case. This tool shows both mappings. Results assume a standard US QWERTY layout. Non-ASCII input is rejected and flagged with the offending character's code point.
Formulas
The ASCII code point of any character is obtained via the JavaScript method:
where codePoint is an integer in the range [0, 127] for standard ASCII. The hexadecimal representation is computed as:
The reverse operation reconstructs the character:
For legacy KeyboardEvent.keyCode values, letters always map to their uppercase ASCII code point regardless of shift state. The relationship is:
Digits map directly: keyCode("0") = 48 through keyCode("9") = 57. Punctuation keycodes are browser-dependent and derived from the physical key position on a US QWERTY layout, not from the character's ASCII value. The HTML entity format follows the pattern &#codePoint; for any numeric reference.
Reference Data
| Dec | Hex | Char | HTML Entity | Description | JS keyCode | Category |
|---|---|---|---|---|---|---|
| 0 | 0x00 | NUL | Null | - | Control | |
| 8 | 0x08 | BS | Backspace | 8 | Control | |
| 9 | 0x09 | HT | Horizontal Tab | 9 | Control | |
| 10 | 0x0A | LF | Line Feed | - | Control | |
| 13 | 0x0D | CR | Carriage Return | 13 | Control | |
| 27 | 0x1B | ESC | Escape | 27 | Control | |
| 32 | 0x20 | SP | Space | 32 | Whitespace | |
| 33 | 0x21 | ! | ! | Exclamation Mark | 49 | Punctuation |
| 34 | 0x22 | " | " | Double Quote | 222 | Punctuation |
| 35 | 0x23 | # | # | Hash / Number Sign | 51 | Punctuation |
| 36 | 0x24 | $ | $ | Dollar Sign | 52 | Punctuation |
| 37 | 0x25 | % | % | Percent | 53 | Punctuation |
| 38 | 0x26 | & | & | Ampersand | 55 | Punctuation |
| 39 | 0x27 | ' | ' | Single Quote / Apostrophe | 222 | Punctuation |
| 40 | 0x28 | ( | ( | Left Parenthesis | 57 | Punctuation |
| 42 | 0x2A | * | * | Asterisk | 56 | Punctuation |
| 43 | 0x2B | + | + | Plus Sign | 187 | Punctuation |
| 44 | 0x2C | , | , | Comma | 188 | Punctuation |
| 45 | 0x2D | - | - | Hyphen / Minus | 189 | Punctuation |
| 46 | 0x2E | . | . | Period / Full Stop | 190 | Punctuation |
| 47 | 0x2F | / | / | Slash | 191 | Punctuation |
| 48 - 57 | 0x30 - 0x39 | 0-9 | 0 - 9 | Digits Zero through Nine | 48 - 57 | Digit |
| 59 | 0x3B | ; | ; | Semicolon | 186 | Punctuation |
| 60 | 0x3C | < | < | Less Than | 188 | Punctuation |
| 61 | 0x3D | = | = | Equals Sign | 187 | Punctuation |
| 62 | 0x3E | > | > | Greater Than | 190 | Punctuation |
| 63 | 0x3F | ? | ? | Question Mark | 191 | Punctuation |
| 64 | 0x40 | @ | @ | At Sign | 50 | Punctuation |
| 65 - 90 | 0x41 - 0x5A | A - Z | A - Z | Uppercase Letters | 65 - 90 | Letter |
| 91 | 0x5B | [ | [ | Left Square Bracket | 219 | Punctuation |
| 92 | 0x5C | \ | \ | Backslash | 220 | Punctuation |
| 93 | 0x5D | ] | ] | Right Square Bracket | 221 | Punctuation |
| 95 | 0x5F | _ | _ | Underscore | 189 | Punctuation |
| 96 | 0x60 | ` | ` | Backtick / Grave Accent | 192 | Punctuation |
| 97 - 122 | 0x61 - 0x7A | a - z | a - z | Lowercase Letters | 65 - 90 | Letter |
| 123 | 0x7B | { | { | Left Curly Brace | 219 | Punctuation |
| 124 | 0x7C | | | | | Vertical Bar / Pipe | 220 | Punctuation |
| 125 | 0x7D | } | } | Right Curly Brace | 221 | Punctuation |
| 126 | 0x7E | ~ | ~ | Tilde | 192 | Punctuation |
| 127 | 0x7F | DEL | | Delete | 46 | Control |