Jump to content

Keyboard Event Character Values for the Lower ASCII Character Set

0
  dannyg1's Photo
Posted Oct 28 2009 02:13 PM

Keyboard events in recent browsers provide information about the keys and, where applicable, characters corresponding to the keys. Character values may be read from the keypress event, while thekey values, including navigation and function keys, are available from keydown and keyup events. The event object properties you use to read these values varies with the event object model. See Chapter 6 of Dynamic HTML: The Definitive Reference for cross-browser implementation details.

The following table reveals the codes for characters in the lower ASCII character set. Some of the codes are for action keys (such as Backspace and Tab), which have character values that are also in this range. Read these values from a keypress event object.

CharacterCharacter value
Backspace8
Tab9
Enter (Return on Mac)13
Space32
!33
"34
#35
$ 36
% 37
&38
' 39
( 40
)41
* 42
+ 43
, 44
- 45
. 46
/ 47
048
1 49
2 50
3 51
4 52
5 53
6 54
755
8 56
9 57
: 58
; 59
< 60
= 61
>62
? 63
@ 64
A 65
B 66
C 67
D68
E 69
F 70
G 71
H 72
I 73
J 74
K75
L 76
M 77
N 78
O 79
P 80
Q 81
R82
S 83
T 84
U 85
V 86
W 87
X 88
Y89
Z 90
[ 91
\ 92
] 93
^ 94
_ 95
` 96
a 97
b 98
c 99
d 100
e 101
f 102
g103
h 104
i 105
j 106
k 107
l 108
m 109
n110
o 111
p 112
q 113
r 114
s 115
t 116
u117
v 118
w 119
x 120
y 121
z 122
{ 123
|124
} 125
~ 126
Delete 127

The following table lists all keys on a typical U. S. English keyboard and their corresponding key codes. Read these codes from an onkeydown or onkeyup event object:

KeyKey value
Alt18
Arrow down40
Arrow left37
Arrow right39
Arrow up38
Backspace8
Caps Lock20
Ctrl17
Delete46
End35
Enter13
Esc27
F1112
F2113
F3114
F4115
F5116
F6117
F7118
F8119
F9120
F10121
F11122
F12123
Home36
Insert45
Num Lock144
(NumPad) -109
(NumPad) *106
(NumPad) .110
(NumPad) /111
(NumPad) +107
(NumPad) 096
(NumPad) 197
(NumPad) 298
(NumPad) 399
(NumPad) 4100
(NumPad) 5101
(NumPad) 6102
(NumPad) 7103
(NumPad) 8104
(NumPad) 9105
Page Down34
Page Up33
Pause19
Print Scrn44
Scroll Lock145
Shift16
Spacebar32
Tab9
A65
B66
C67
D68
E69
F70
G71
H72
I73
J74
K75
L76
M77
N78
O79
P80
Q81
R82
S83
T84
U85
V86
W87
X88
Y89
Z90
149
250
351
452
553
654
755
856
957
048
`222
-189
,188
.190
/191
;186
[219
\220
]221
`192
=187
Dynamic HTML: The Definitive Reference

Learn more about this topic from Dynamic HTML: The Definitive Reference, 3rd Edition.

Packed with information on the latest web specifications and browser features, this new edition is your ultimate one-stop resource for HTML, XHTML, CSS, Document Object Model (DOM), and Javascript development. Here is the comprehensive reference for designers of Rich Internet Applications who need to operate in all modern browsers, including Internet Explorer 7, Firefox 2, Safari, and Opera. You can instantly see browser support for the latest standards-based technologies.

See what you'll learn


Tags:
0 Subscribe


0 Replies