Appendix A. Keyboard Event Character Values
Keyboard events in recent browsers provide information about the keys and, where applicable, about the characters corresponding to the keys. Character values may be read from the keypress event. The following table reveals the codes for characters in the lower ASCII character set. Some of these codes are for action keys (such as Back-space and Tab), whose character values are also in this range.
Character | Value | Character | Value |
Backspace | 8 | 0 | 48 |
Tab | 9 | 1 | 49 |
Enter (Return on Mac) | 13 | 2 | 50 |
Space | 32 | 3 | 51 |
! | 33 | 4 | 52 |
" | 34 | 5 | 53 |
# | 35 | 6 | 54 |
$ | 36 | 7 | 55 |
% | 37 | 8 | 56 |
& | 38 | 9 | 57 |
' | 39 | : | 58 |
( | 40 | ; | 59 |
) | 41 | < | 60 |
* | 42 | = | 61 |
+ | 43 | > | 62 |
, | 44 | ? | 63 |
- | 45 | @ | 64 |
. | 46 | A | 65 |
/ | 47 | B | 66 |
C | 67 | b | 98 |
D | 68 | c | 99 |
E | 69 | d | 100 |
F | 70 | e | 101 |
G | 71 | f | 102 |
H | 72 | g | 103 |
I | 73 | h | 104 |
J | 74 | k | 105 |
K | 75 | l | 106 |
L | 76 | m | 107 |
M | 77 | l | 108 |
N | 78 | m | 109 |
O | 79 | n | 110 |
P | 80 | o | 111 |
Q | 81 | p | 112 |
R | 82 | q | 113 |
S | 83 | r | 114 |
T | 84 | s | 115 |
U | 85 | t | 116 |
V | 86 | u | 117 |
W | 87 | v | 118 |
X | 88 | w | 119 |
Y | 89 | x | 120 |
Z | 90 | y | 121 |
[ | 91 | z | 122 |
\ | 92 | { | 123 |
] | 93 | | | 124 |
^ | 94 | } | 125 |
_ | 95 | ~ | 126 |
' | 96 | Delete | 127 |
a | 97 |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access