User Rating 0.0
Total Usage 0 times
Output format:
Separator:
Is this tool helpful?

Your feedback helps us improve.

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.

ascii keycode charcode javascript keycode ascii table key event character code converter

Formulas

The ASCII code point of any character is obtained via the JavaScript method:

codePoint = charCodeAt(index)

where codePoint is an integer in the range [0, 127] for standard ASCII. The hexadecimal representation is computed as:

hex = toString(16)

The reverse operation reconstructs the character:

char = String.fromCharCode(codePoint)

For legacy KeyboardEvent.keyCode values, letters always map to their uppercase ASCII code point regardless of shift state. The relationship is:

keyCode("a") = keyCode("A") = 65

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

DecHexCharHTML EntityDescriptionJS keyCodeCategory
00x00NULNull - Control
80x08BSBackspace8Control
90x09HT Horizontal Tab9Control
100x0ALF Line Feed - Control
130x0DCR Carriage Return13Control
270x1BESCEscape27Control
320x20SP Space32Whitespace
330x21!!Exclamation Mark49Punctuation
340x22""Double Quote222Punctuation
350x23##Hash / Number Sign51Punctuation
360x24$$Dollar Sign52Punctuation
370x25%%Percent53Punctuation
380x26&&Ampersand55Punctuation
390x27''Single Quote / Apostrophe222Punctuation
400x28((Left Parenthesis57Punctuation
420x2A**Asterisk56Punctuation
430x2B++Plus Sign187Punctuation
440x2C,,Comma188Punctuation
450x2D--Hyphen / Minus189Punctuation
460x2E..Period / Full Stop190Punctuation
470x2F//Slash191Punctuation
48 - 570x30 - 0x390-90 - 9Digits Zero through Nine48 - 57Digit
590x3B;;Semicolon186Punctuation
600x3C<<Less Than188Punctuation
610x3D==Equals Sign187Punctuation
620x3E>>Greater Than190Punctuation
630x3F??Question Mark191Punctuation
640x40@@At Sign50Punctuation
65 - 900x41 - 0x5AA - ZA - ZUppercase Letters65 - 90Letter
910x5B[[Left Square Bracket219Punctuation
920x5C\\Backslash220Punctuation
930x5D]]Right Square Bracket221Punctuation
950x5F__Underscore189Punctuation
960x60``Backtick / Grave Accent192Punctuation
97 - 1220x61 - 0x7Aa - za - zLowercase Letters65 - 90Letter
1230x7B{{Left Curly Brace219Punctuation
1240x7C||Vertical Bar / Pipe220Punctuation
1250x7D}}Right Curly Brace221Punctuation
1260x7E~~Tilde192Punctuation
1270x7FDELDelete46Control

Frequently Asked Questions

The deprecated KeyboardEvent.keyCode property represents the physical key, not the character produced. Both "a" and "A" are generated by the same physical key, so both return keyCode 65 (the uppercase ASCII value). To distinguish case, use KeyboardEvent.key which returns the actual character ('a' vs 'A'), or check the shiftKey modifier property.
All three are deprecated. keyCode was set on keydown/keyup and indicated the physical key. charCode was set on the keypress event and represented the Unicode value of the character. event.which was a cross-browser normalization that returned whichever of the two was available. Modern code should use KeyboardEvent.key (the string character) and KeyboardEvent.code (the physical key identifier like 'KeyA').
Keycodes for punctuation map to the physical key position on a US QWERTY keyboard, not to the character's ASCII code point. For example, the semicolon character has ASCII code 59, but keyCode 186, because the browser identifies the physical key, not the output glyph. This mapping varies across keyboard layouts and browsers. Chrome and Firefox historically disagreed on several punctuation keycodes.
This tool covers the standard 7-bit ASCII range (0-127). Characters above 127 fall into Extended ASCII (128-255, encoding-dependent) or Unicode. For Unicode, use codePointAt() instead of charCodeAt() to correctly handle surrogate pairs (emoji, CJK characters). The keyCode property does not reliably represent Unicode characters beyond the basic Latin set.
Most control characters (NUL, SOH, STX, etc.) are relics of teletype communication. However, several remain critical: HT (9, Tab), LF (10, newline in Unix/macOS), CR (13, Enter key and part of Windows CRLF line endings), ESC (27, closing modals/menus), and BS (8, Backspace). Web applications routinely intercept keycodes 9, 13, 27, and 8 for navigation and form handling.
Yes. The live capture panel reports the keyCode, key, and code for any key press including modifiers. Ctrl alone returns keyCode 17, Shift returns 16, Alt returns 18, and Meta (Cmd/Win) returns 91. Combinations like Ctrl+A will show keyCode 65 for the "A" key with the ctrlKey modifier flag set to true. Some browser shortcuts (Ctrl+W, Ctrl+T) may be intercepted by the browser before reaching the page.