What is the list of KeyCodes for JavaScript KeyDown KeyPress and KeyUp events?
Copyright © 2007-2012 www.AspDotNetFaq.com
Very often when programming in ASP.NET and ASP.NET AJAX we have to write JavaScript code.
When writing JavaScript that interacts with user we have to deal with keyboard events.
In every modern browser there are three possible kinds of client-side events triggered when a keyboard key is pressed or released:
- keydown event
- keypress event
- keyup event
The keydown event occurs when the keyboard key is pressed, and it is followed at once by the execution of keypress event.
The keyup event is generated when the key is released.
Here is the list of (almost) all JavaScript KeyCodes for Firefox and Internet Explorer we could find:
|
Keyboard key Pressed
|
IE JavaScript Key Code value
|
Firefox JavaScript Key Code value
|
|
backspace
|
8
|
8
|
|
|
tab
|
9
|
9
|
|
|
enter
|
13
|
13
|
|
|
shift
|
16
|
16
|
|
|
ctrl
|
17
|
17
|
|
|
alt
|
18
|
18
|
|
|
pause/break
|
19
|
19
|
|
|
caps lock
|
20
|
20
|
|
|
escape
|
27
|
27
|
|
|
page up
|
33
|
33
|
|
|
Space
|
32
|
32
|
|
|
page down
|
34
|
34
|
|
|
end
|
35
|
35
|
|
|
home
|
36
|
36
|
|
|
arrow left
|
37
|
37
|
|
|
arrow up
|
38
|
38
|
|
|
arrow right
|
39
|
39
|
|
|
arrow down
|
40
|
40
|
|
|
print screen
|
44
|
44
|
|
|
insert
|
45
|
45
|
|
|
delete
|
46
|
46
|
|
|
0
|
48
|
48
|
|
|
1
|
49
|
49
|
|
|
2
|
50
|
50
|
|
|
3
|
51
|
51
|
|
|
4
|
52
|
52
|
|
|
5
|
53
|
53
|
|
|
6
|
54
|
54
|
|
|
7
|
55
|
55
|
|
|
8
|
56
|
56
|
|
|
9
|
57
|
57
|
|
|
a
|
65
|
65
|
|
|
b
|
66
|
66
|
|
|
c
|
67
|
67
|
|
|
d
|
68
|
68
|
|
|
e
|
69
|
69
|
|
|
f
|
70
|
70
|
|
|
g
|
71
|
71
|
|
|
h
|
72
|
72
|
|
|
i
|
73
|
73
|
|
|
j
|
74
|
74
|
|
|
k
|
75
|
75
|
|
|
l
|
76
|
76
|
|
|
m
|
77
|
77
|
|
|
n
|
78
|
78
|
|
|
o
|
79
|
79
|
|
|
p
|
80
|
80
|
|
|
q
|
81
|
81
|
|
|
r
|
82
|
82
|
|
|
s
|
83
|
83
|
|
|
t
|
84
|
84
|
|
|
u
|
85
|
85
|
|
|
v
|
86
|
86
|
|
|
w
|
87
|
87
|
|
|
x
|
88
|
88
|
|
|
y
|
89
|
89
|
|
|
z
|
90
|
90
|
|
|
left window key
|
91
|
91
|
|
|
right window key
|
92
|
92
|
|
|
select key
|
93
|
93
|
|
|
numpad 0
|
96
|
96
|
|
|
numpad 1
|
97
|
97
|
|
|
numpad 2
|
98
|
98
|
|
|
numpad 3
|
99
|
99
|
|
|
numpad 4
|
100
|
100
|
|
|
numpad 5
|
101
|
101
|
|
|
numpad 6
|
102
|
102
|
|
|
numpad 7
|
103
|
103
|
|
|
numpad 8
|
104
|
104
|
|
|
numpad 9
|
105
|
105
|
|
|
multiply
|
106
|
106
|
|
|
add
|
107
|
107
|
|
|
subtract
|
109
|
109
|
|
|
decimal point
|
110
|
110
|
|
|
divide
|
111
|
111
|
|
|
f1
|
112
|
112
|
|
|
f2
|
113
|
113
|
|
|
f3
|
114
|
114
|
|
|
f4
|
115
|
115
|
|
|
f5
|
116
|
116
|
|
|
f6
|
117
|
117
|
|
|
f7
|
118
|
118
|
|
|
f8
|
119
|
119
|
|
|
f9
|
120
|
120
|
|
|
f10
|
121
|
121
|
|
|
f11
|
122
|
122
|
|
|
f12
|
123
|
123
|
|
|
num lock
|
144
|
144
|
|
|
scroll lock
|
145
|
145
|
|
|
My Computer (multimedia keyboard)
|
182
|
182
|
|
|
My Calculator (multimedia keyboard)
|
183
|
183
|
|
|
semi-colon
|
186
|
186
|
|
|
equal sign
|
187
|
107
|
|
|
comma
|
188
|
188
|
|
|
dash
|
189
|
189
|
|
|
period
|
190
|
190
|
|
|
forward slash
|
191
|
191
|
|
|
open bracket
|
219
|
219
|
|
|
back slash
|
220
|
220
|
|
|
close bracket
|
221
|
221
|
|
|
single quote
|
222
|
222
|
|
Please Let us know if you notice some Key Codes we missed!
Copyright © 2007-2012 www.AspDotNetFaq.com