|
|
|
|
Win FREE BOOK from Kodyaz
|
How to get Javascript Key Codes of Characters using Javascript Code and Key Code List
In this Javascript tutorial, web developers can get javascript key codes of characters or keys entered by using javascript codes.
I hope Javascript developers will find useful this javascript keycode list in this tutorial.
In order to see the javascript key code of a key, press any key in the below textbox.
The key code of the pressed key or character will be displayed on the next textbox.
Javascript developers can use the below free javascript code, javascript KeyCode function in their scripts to get the pressed key's key code.
As you will see, the javascript trick here is using the window.event
function KeyCode(e){
if(e){
e = e
} else {
e = window.event
}
if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}
document.all.t2.value = keycode
}
Here is the Javascript key code list that is most common.
The key code list includes numbers (also numbers in the number pad), characters, function keys, and special key codes.
| Key |
Key Code |
| 0 |
48 |
| 1 |
49 |
| 2 |
50 |
| 3 |
51 |
| 4 |
52 |
| 5 |
53 |
| 6 |
54 |
| 7 |
55 |
| 8 |
56 |
| 9 |
57 |
| Key |
Key Code |
| A |
65 |
| B |
66 |
| C |
67 |
| D |
68 |
| E |
69 |
| F |
70 |
| G |
71 |
| H |
72 |
| I |
73 |
| J |
74 |
| K |
75 |
| L |
76 |
| M |
77 |
| N |
78 |
| O |
79 |
| P |
80 |
| Q |
81 |
| R |
82 |
| S |
83 |
| T |
84 |
| U |
85 |
| V |
86 |
| W |
87 |
| X |
88 |
| Y |
89 |
| Z |
90 |
| Key |
Key Code |
| F1 |
112 |
| F2 |
113 |
| F3 |
114 |
| F4 |
115 |
| F5 |
116 |
| F6 |
117 |
| F7 |
118 |
| F8 |
119 |
| F9 |
120 |
| F10 |
121 |
| F11 |
122 |
| F12 |
123 |
| Key |
Key Code |
| Number Pad 0 |
96 |
| Number Pad 1 |
97 |
| Number Pad 2 |
98 |
| Number Pad 3 |
99 |
| Number Pad 4 |
100 |
| Number Pad 5 |
101 |
| Number Pad 6 |
102 |
| Number Pad 7 |
103 |
| Number Pad 8 |
104 |
| Number Pad 9 |
105 |
| Key |
Key Code |
| BACKSPACE |
8 |
| TAB |
9 |
| ENTER |
13 |
| SHIFT |
16 |
| CTRL |
17 |
| ALT |
18 |
| PAUSE/BREAK |
19 |
| CAPS LOCK |
20 |
| ESCAPE |
27 |
| PAGE UP |
33 |
| PAGE DOWN |
34 |
| END |
35 |
| HOME |
36 |
| LEFT ARROW |
37 |
| UP ARROW |
38 |
| RIGHT ARROW |
39 |
| DOWN ARROW |
40 |
| INSERT |
45 |
| DELETE |
46 |
| LEFT WINDOW KEY |
91 |
| RIGHT WINDOW KEY |
92 |
| SELECT KEY |
93 |
| MULTIPLY |
106 |
| ADD |
107 |
| SUBTRACT |
109 |
| DECIMAL POINT |
110 |
| DIVIDE |
111 |
| NUM LOCK |
144 |
| SCROLL LOCK |
145 |
| SEMI-COLON |
186 |
| EQUAL SIGN |
187 |
| COMMA |
188 |
| DASH |
189 |
| PERIOD |
190 |
| FORWARD SLASH |
191 |
| GRAVE ACCENT |
192 |
| OPEN BRACKET |
219 |
| BACK SLASH |
220 |
| CLOSE BRAKET |
221 |
| SINGLE QUOTE |
222 |
|
|
|
|
|
|
|
|
|
|