Javascript Char Codes (Key Codes) - Accipiter Research

2013-01-31

      Javascript Char Codes (Key Codes) - Accipiter Research

  with my learn of the art and science of JavaScript , i find the keyboard is useful for our web application too , so i make a simply search of the keycode of the javascript ,it's very useful , it may help you too.

Press a key in the text box below to see the corresponding Javascript key code. Or scroll down to see the full list.

Try it!    

 

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
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
a 65
b 66
c 67
d 68
 
Key Code
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
left window key 91
right window key 92
select key 93
numpad 0 96
numpad 1 97
numpad 2 98
numpad 3 99
numpad 4 100
numpad 5 101
numpad 6 102
numpad 7 103
 
Key Code
numpad 8 104
numpad 9 105
multiply 106
add 107
subtract 109
decimal point 110
divide 111
f1 112
f2 113
f3 114
f4 115
f5 116
f6 117
f7 118
f8 119
f9 120
f10 121
f11 122
f12 123
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
  

source code:

 

View Code
  1  
  2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  4 <head><title>
  5             Javascript Char Codes (Key Codes) - Accipiter Research
  6         </title>
  7 </head>
  8 <body>
  9 <form >
 10 <SCRIPT language="javascript"> 
 11  <!--
 12  function displayKeyCode(evt)
 13  {
 14     var textBox = getObject('txtChar');
 15      var charCode = (evt.which) ? evt.which : event.keyCode
 16      textBox.value = String.fromCharCode(charCode);
 17      if (charCode == 8) textBox.value = "backspace"; //  backspace
 18      if (charCode == 9) textBox.value = "tab"; //  tab
 19      if (charCode == 13) textBox.value = "enter"; //  enter
 20      if (charCode == 16) textBox.value = "shift"; //  shift
 21      if (charCode == 17) textBox.value = "ctrl"; //  ctrl
 22      if (charCode == 18) textBox.value = "alt"; //  alt
 23      if (charCode == 19) textBox.value = "pause/break"; //  pause/break
 24      if (charCode == 20) textBox.value = "caps lock"; //  caps lock
 25      if (charCode == 27) textBox.value = "escape"; //  escape
 26      if (charCode == 33) textBox.value = "page up"; // page up, to avoid displaying alternate character and confusing people             
 27      if (charCode == 34) textBox.value = "page down"; // page down
 28      if (charCode == 35) textBox.value = "end"; // end
 29      if (charCode == 36) textBox.value = "home"; // home
 30      if (charCode == 37) textBox.value = "left arrow"; // left arrow
 31      if (charCode == 38) textBox.value = "up arrow"; // up arrow
 32      if (charCode == 39) textBox.value = "right arrow"; // right arrow
 33      if (charCode == 40) textBox.value = "down arrow"; // down arrow
 34      if (charCode == 45) textBox.value = "insert"; // insert
 35      if (charCode == 46) textBox.value = "delete"; // delete
 36      if (charCode == 91) textBox.value = "left window"; // left window
 37      if (charCode == 92) textBox.value = "right window"; // right window
 38      if (charCode == 93) textBox.value = "select key"; // select key
 39      if (charCode == 96) textBox.value = "numpad 0"; // numpad 0
 40      if (charCode == 97) textBox.value = "numpad 1"; // numpad 1
 41      if (charCode == 98) textBox.value = "numpad 2"; // numpad 2
 42      if (charCode == 99) textBox.value = "numpad 3"; // numpad 3
 43      if (charCode == 100) textBox.value = "numpad 4"; // numpad 4
 44      if (charCode == 101) textBox.value = "numpad 5"; // numpad 5
 45      if (charCode == 102) textBox.value = "numpad 6"; // numpad 6
 46      if (charCode == 103) textBox.value = "numpad 7"; // numpad 7
 47      if (charCode == 104) textBox.value = "numpad 8"; // numpad 8
 48      if (charCode == 105) textBox.value = "numpad 9"; // numpad 9
 49      if (charCode == 106) textBox.value = "multiply"; // multiply
 50      if (charCode == 107) textBox.value = "add"; // add
 51      if (charCode == 109) textBox.value = "subtract"; // subtract
 52      if (charCode == 110) textBox.value = "decimal point"; // decimal point
 53      if (charCode == 111) textBox.value = "divide"; // divide
 54      if (charCode == 112) textBox.value = "F1"; // F1
 55      if (charCode == 113) textBox.value = "F2"; // F2
 56      if (charCode == 114) textBox.value = "F3"; // F3
 57      if (charCode == 115) textBox.value = "F4"; // F4
 58      if (charCode == 116) textBox.value = "F5"; // F5
 59      if (charCode == 117) textBox.value = "F6"; // F6
 60      if (charCode == 118) textBox.value = "F7"; // F7
 61      if (charCode == 119) textBox.value = "F8"; // F8
 62      if (charCode == 120) textBox.value = "F9"; // F9
 63      if (charCode == 121) textBox.value = "F10"; // F10
 64      if (charCode == 122) textBox.value = "F11"; // F11
 65      if (charCode == 123) textBox.value = "F12"; // F12
 66      if (charCode == 144) textBox.value = "num lock"; // num lock
 67      if (charCode == 145) textBox.value = "scroll lock"; // scroll lock
 68      if (charCode == 186) textBox.value = ";"; // semi-colon
 69      if (charCode == 187) textBox.value = "="; // equal-sign
 70      if (charCode == 188) textBox.value = ","; // comma
 71      if (charCode == 189) textBox.value = "-"; // dash
 72      if (charCode == 190) textBox.value = "."; // period
 73      if (charCode == 191) textBox.value = "/"; // forward slash
 74      if (charCode == 192) textBox.value = "`"; // grave accent
 75      if (charCode == 219) textBox.value = "["; // open bracket
 76      if (charCode == 220) textBox.value = "\\"; // back slash
 77      if (charCode == 221) textBox.value = "]"; // close bracket
 78      if (charCode == 222) textBox.value = "'"; // single quote
 79  
 80      var lblCharCode = getObject('spnCode');
 81     lblCharCode.innerHTML = 'JavaScript KeyCode:  ' + charCode;
 82  
 83     return false;
 84  
 85  }
 86  function getObject(obj)
 87   {
 88       var theObj;
 89       if (document.all) {
 90           if (typeof obj=='string') {
 91               return document.all(obj);
 92           } else {
 93               return obj.style;
 94           }
 95       }
 96       if (document.getElementById) {
 97           if (typeof obj=='string') {
 98               return document.getElementById(obj);
 99           } else {
100               return obj.style;
101           }
102       }
103       return null;
104   }
105  //-->
106 </SCRIPT>
107 Press a key in the text box below to see the corresponding Javascript key code. Or scroll down to see the full list. 
108 <br><br>
109 Try it! <INPUT ONKEYPRESS="javascript:return false;" ID="txtChar" ONKEYDOWN="javascript:return displayKeyCode(event)" TYPE="text" NAME="txtChar">&nbsp;&nbsp;&nbsp;
110 <SPAN ID="spnCode" NAME="spnCode"></SPAN>
111 <p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
112 <html xmlns="http://www.w3.org/1999/xhtml">
113     <head>
114         <title>Untitled Page</title>
115     </head>
116     <body>
117         <table>
118             <tr>
119                 <td style="vertical-align:top;">
120                     <table id="TABLE2" class="tableStyleAlternating" cellspacing="0">
121                         <tr style="color: white; background-color: dimgray;">
122                             <td style="width:120px;white-space:normal;">
123                                 Key
124                             </td>
125                             <td style="width:55px;white-space:normal;">
126                                 Code
127                             </td>
128                         </tr>
129                         <tr>
130                             <td>
131                                 backspace
132                             </td>
133                             <td>
134                                 8
135                             </td>
136                         </tr>
137                         <tr>
138                             <td>
139                                 tab
140                             </td>
141                             <td>
142                                 9
143                             </td>
144                         </tr>
145                         <tr>
146                             <td>
147                                 enter
148                             </td>
149                             <td>
150                                 13
151                             </td>
152                         </tr>
153                         <tr>
154                             <td>
155                                 shift
156                             </td>
157                             <td>
158                                 16
159                             </td>
160                         </tr>
161                         <tr>
162                             <td>
163                                 ctrl
164                             </td>
165                             <td>
166                                 17
167                             </td>
168                         </tr>
169                         <tr>
170                             <td>
171                                 alt
172                             </td>
173                             <td>
174                                 18
175                             </td>
176                         </tr>
177                         <tr>
178                             <td>
179                                 pause/break
180                             </td>
181                             <td>
182                                 19
183                             </td>
184                         </tr>
185                         <tr>
186                             <td>
187                                 caps lock
188                             </td>
189                             <td>
190                                 20
191                             </td>
192                         </tr>
193                         <tr>
194                             <td>
195                                 escape
196                             </td>
197                             <td>
198                                 27
199                             </td>
200                         </tr>
201                         <tr>
202                             <td>
203                                 page up
204                             </td>
205                             <td>
206                                 33
207                             </td>
208                         </tr>
209                         <tr>
210                             <td>
211                                 page down
212                             </td>
213                             <td>
214                                 34
215                             </td>
216                         </tr>
217                         <tr>
218                             <td>
219                                 end
220                             </td>
221                             <td>
222                                 35
223                             </td>
224                         </tr>
225                         <tr>
226                             <td>
227                                 home
228                             </td>
229                             <td>
230                                 36
231                             </td>
232                         </tr>
233                         <tr>
234                             <td>
235                                 left arrow
236                             </td>
237                             <td>
238                                 37
239                             </td>
240                         </tr>
241                         <tr>
242                             <td>
243                                 up arrow
244                             </td>
245                             <td>
246                                 38
247                             </td>
248                         </tr>
249                         <tr>
250                             <td>
251                                 right arrow
252                             </td>
253                             <td>
254                                 39
255                             </td>
256                         </tr>
257                         <tr>
258                             <td>
259                                 down arrow
260                             </td>
261                             <td>
262                                 40
263                             </td>
264                         </tr>
265                         <tr>
266                             <td>
267                                 insert
268                             </td>
269                             <td>
270                                 45
271                             </td>
272                         </tr>
273                         <tr>
274                             <td>
275                                 delete
276                             </td>
277                             <td>
278                                 46
279                             </td>
280                         </tr>
281                         <tr>
282                             <td>
283                                 0
284                             </td>
285                             <td>
286                                 48
287                             </td>
288                         </tr>
289                         <tr>
290                             <td>
291                                 1
292                             </td>
293                             <td>
294                                 49
295                             </td>
296                         </tr>
297                         <tr>
298                             <td>
299                                 2
300                             </td>
301                             <td>
302                                 50
303                             </td>
304                         </tr>
305                         <tr>
306                             <td>
307                                 3
308                             </td>
309                             <td>
310                                 51
311                             </td>
312                         </tr>
313                         <tr>
314                             <td>
315                                 4
316                             </td>
317                             <td>
318                                 52
319                             </td>
320                         </tr>
321                         <tr>
322                             <td>
323                                 5
324                             </td>
325                             <td>
326                                 53
327                             </td>
328                         </tr>
329                         <tr>
330                             <td>
331                                 6
332                             </td>
333                             <td>
334                                 54
335                             </td>
336                         </tr>
337                         <tr>
338                             <td>
339                                 7
340                             </td>
341                             <td>
342                                 55
343                             </td>
344                         </tr>
345                         <tr>
346                             <td>
347                                 8
348                             </td>
349                             <td>
350                                 56
351                             </td>
352                         </tr>
353                         <tr>
354                             <td>
355                                 9
356                             </td>
357                             <td>
358                                 57
359                             </td>
360                         </tr>
361                         <tr>
362                             <td>
363                                 a
364                             </td>
365                             <td>
366                                 65
367                             </td>
368                         </tr>
369                         <tr>
370                             <td>
371                                 b
372                             </td>
373                             <td>
374                                 66
375                             </td>
376                         </tr>
377                         <tr>
378                             <td>
379                                 c
380                             </td>
381                             <td>
382                                 67
383                             </td>
384                         </tr>
385                         <tr>
386                             <td>
387                                 d
388                             </td>
389                             <td>
390                                 68
391                             </td>
392                         </tr>
393                     </table>
394                 </td>
395                 <td>&nbsp;</td>
396                 <td style="vertical-align:top;">
397                     <table id="TABLE1" class="tableStyleAlternating" cellspacing="0">
398                         <tr style="color: white; background-color: dimgray;">
399                             <td style="width:120px;white-space:normal;">
400                                 Key
401                             </td>
402                             <td style="width:55px;white-space:normal;">
403                                 Code
404                             </td>
405                         </tr>
406                         <tr>
407                             <td>
408                                 e
409                             </td>
410                             <td>
411                                 69
412                             </td>
413                         </tr>
414                         <tr>
415                             <td>
416                                 f
417                             </td>
418                             <td>
419                                 70
420                             </td>
421                         </tr>
422                         <tr>
423                             <td>
424                                 g
425                             </td>
426                             <td>
427                                 71
428                             </td>
429                         </tr>
430                         <tr>
431                             <td>
432                                 h
433                             </td>
434                             <td>
435                                 72
436                             </td>
437                         </tr>
438                         <tr>
439                             <td>
440                                 i
441                             </td>
442                             <td>
443                                 73
444                             </td>
445                         </tr>
446                         <tr>
447                             <td>
448                                 j
449                             </td>
450                             <td>
451                                 74
452                             </td>
453                         </tr>
454                         <tr>
455                             <td>
456                                 k
457                             </td>
458                             <td>
459                                 75
460                             </td>
461                         </tr>
462                         <tr>
463                             <td>
464                                 l
465                             </td>
466                             <td>
467                                 76
468                             </td>
469                         </tr>
470                         <tr>
471                             <td>
472                                 m
473                             </td>
474                             <td>
475                                 77
476                             </td>
477                         </tr>
478                         <tr>
479                             <td>
480                                 n
481                             </td>
482                             <td>
483                                 78
484                             </td>
485                         </tr>
486                         <tr>
487                             <td>
488                                 o
489                             </td>
490                             <td>
491                                 79
492                             </td>
493                         </tr>
494                         <tr>
495                             <td>
496                                 p
497                             </td>
498                             <td>
499                                 80
500                             </td>
501                         </tr>
502                         <tr>
503                             <td>
504                                 q
505                             </td>
506                             <td>
507                                 81
508                             </td>
509                         </tr>
510                         <tr>
511                             <td>
512                                 r
513                             </td>
514                             <td>
515                                 82
516                             </td>
517                         </tr>
518                         <tr>
519                             <td>
520                                 s
521                             </td>
522                             <td>
523                                 83
524                             </td>
525                         </tr>
526                         <tr>
527                             <td>
528                                 t
529                             </td>
530                             <td>
531                                 84
532                             </td>
533                         </tr>
534                         <tr>
535                             <td>
536                                 u
537                             </td>
538                             <td>
539                                 85
540                             </td>
541                         </tr>
542                         <tr>
543                             <td>
544                                 v
545                             </td>
546                             <td>
547                                 86
548                             </td>
549                         </tr>
550                         <tr>
551                             <td>
552                                 w
553                             </td>
554                             <td>
555                                 87
556                             </td>
557                         </tr>
558                         <tr>
559                             <td>
560                                 x
561                             </td>
562                             <td>
563                                 88
564                             </td>
565                         </tr>
566                         <tr>
567                             <td>
568                                 y
569                             </td>
570                             <td>
571                                 89
572                             </td>
573                         </tr>
574                         <tr>
575                             <td>
576                                 z
577                             </td>
578                             <td>
579                                 90
580                             </td>
581                         </tr>
582                         <tr>
583                             <td>
584                                 left window key
585                             </td>
586                             <td>
587                                 91
588                             </td>
589                         </tr>
590                         <tr>
591                             <td>
592                                 right window key
593                             </td>
594                             <td>
595                                 92
596                             </td>
597                         </tr>
598                         <tr>
599                             <td>
600                                 select key
601                             </td>
602                             <td>
603                                 93
604                             </td>
605                         </tr>
606                         <tr>
607                             <td>
608                                 numpad 0
609                             </td>
610                             <td>
611                                 96
612                             </td>
613                         </tr>
614                         <tr>
615                             <td>
616                                 numpad 1
617                             </td>
618                             <td>
619                                 97
620                             </td>
621                         </tr>
622                         <tr>
623                             <td>
624                                 numpad 2
625                             </td>
626                             <td>
627                                 98
628                             </td>
629                         </tr>
630                         <tr>
631                             <td>
632                                 numpad 3
633                             </td>
634                             <td>
635                                 99
636                             </td>
637                         </tr>
638                         <tr>
639                             <td>
640                                 numpad 4
641                             </td>
642                             <td>
643                                 100
644                             </td>
645                         </tr>
646                         <tr>
647                             <td>
648                                 numpad 5
649                             </td>
650                             <td>
651                                 101
652                             </td>
653                         </tr>
654                         <tr>
655                             <td>
656                                 numpad 6
657                             </td>
658                             <td>
659                                 102
660                             </td>
661                         </tr>
662                         <tr>
663                             <td>
664                                 numpad 7
665                             </td>
666                             <td>
667                                 103
668                             </td>
669                         </tr>
670                     </table>
671                 </td>
672                 <td>&nbsp;</td>
673                 <td style="vertical-align:top;">
674                     <table id="TABLE3" class="tableStyleAlternating" cellspacing="0">
675                         <tr style="color: white; background-color: dimgray;">
676                             <td style="width:120px;white-space:normal;">
677                                 Key
678                             </td>
679                             <td style="width:55px;white-space:normal;">
680                                 Code
681                             </td>
682                         </tr>
683                         <tr>
684                             <td>
685                                 numpad 8
686                             </td>
687                             <td>
688                                 104
689                             </td>
690                         </tr>
691                         <tr>
692                             <td>
693                                 numpad 9
694                             </td>
695                             <td>
696                                 105
697                             </td>
698                         </tr>
699                         <tr>
700                             <td>
701                                 multiply
702                             </td>
703                             <td>
704                                 106
705                             </td>
706                         </tr>
707                         <tr>
708                             <td>
709                                 add
710                             </td>
711                             <td>
712                                 107
713                             </td>
714                         </tr>
715                         <tr>
716                             <td>
717                                 subtract
718                             </td>
719                             <td>
720                                 109
721                             </td>
722                         </tr>
723                         <tr>
724                             <td>
725                                 decimal point
726                             </td>
727                             <td>
728                                 110
729                             </td>
730                         </tr>
731                         <tr>
732                             <td>
733                                 divide
734                             </td>
735                             <td>
736                                 111
737                             </td>
738                         </tr>
739                         <tr>
740                             <td>
741                                 f1
742                             </td>
743                             <td>
744                                 112
745                             </td>
746                         </tr>
747                         <tr>
748                             <td>
749                                 f2
750                             </td>
751                             <td>
752                                 113
753                             </td>
754                         </tr>
755                         <tr>
756                             <td>
757                                 f3
758                             </td>
759                             <td>
760                                 114
761                             </td>
762                         </tr>
763                         <tr>
764                             <td>
765                                 f4
766                             </td>
767                             <td>
768                                 115
769                             </td>
770                         </tr>
771                         <tr>
772                             <td>
773                                 f5
774                             </td>
775                             <td>
776                                 116
777                             </td>
778                         </tr>
779                         <tr>
780                             <td>
781                                 f6
782                             </td>
783                             <td>
784                                 117
785                             </td>
786                         </tr>
787                         <tr>
788                             <td>
789                                 f7
790                             </td>
791                             <td>
792                                 118
793                             </td>
794                         </tr>
795                         <tr>
796                             <td>
797                                 f8
798                             </td>
799                             <td>
800                                 119
801                             </td>
802                         </tr>
803                         <tr>
804                             <td>
805                                 f9
806                             </td>
807                             <td>
808                                 120
809                             </td>
810                         </tr>
811                         <tr>
812                             <td>
813                                 f10
814                             </td>
815                             <td>
816                                 121
817                             </td>
818                         </tr>
819                         <tr>
820                             <td>
821                                 f11
822                             </td>
823                             <td>
824                                 122
825                             </td>
826                         </tr>
827                         <tr>
828                             <td>
829                                 f12
830                             </td>
831                             <td>
832                                 123
833                             </td>
834                         </tr>
835                         <tr>
836                             <td>
837                                 num lock
838                             </td>
839                             <td>
840                                 144
841                             </td>
842                         </tr>
843                         <tr>
844                             <td>
845                                 scroll lock
846                             </td>
847                             <td>
848                                 145
849                             </td>
850                         </tr>
851                         <tr>
852                             <td>
853                                 semi-colon
854                             </td>
855                             <td>
856                                 186
857                             </td>
858                         </tr>
859                         <tr>
860                             <td>
861                                 equal sign
862                             </td>
863                             <td>
864                                 187
865                             </td>
866                         </tr>
867                         <tr>
868                             <td>
869                                 comma
870                             </td>
871                             <td>
872                                 188
873                             </td>
874                         </tr>
875                         <tr>
876                             <td>
877                                 dash
878                             </td>
879                             <td>
880                                 189
881                             </td>
882                         </tr>
883                         <tr>
884                             <td>
885                                 period
886                             </td>
887                             <td>
888                                 190
889                             </td>
890                         </tr>
891                         <tr>
892                             <td>
893                                 forward slash
894                             </td>
895                             <td>
896                                 191
897                             </td>
898                         </tr>
899                         <tr>
900                             <td>
901                                 grave accent
902                             </td>
903                             <td>
904                                 192
905                             </td>
906                         </tr>
907                         <tr>
908                             <td>
909                                 open bracket
910                             </td>
911                             <td>
912                                 219
913                             </td>
914                         </tr>
915                         <tr>
916                             <td>
917                                 back slash
918                             </td>
919                             <td>
920                                 220
921                             </td>
922                         </tr>
923                         <tr>
924                             <td>
925                                 close braket
926                             </td>
927                             <td>
928                                 221
929                             </td>
930                         </tr>
931                         <tr>
932                             <td>
933                                 single quote
934                             </td>
935                             <td>
936                                 222
937                             </td>
938                         </tr>
939                         <tr>
940                             <td>
941                             </td>
942                             <td>
943                             </td>
944                         </tr>
945                     </table>
946                 </td>
947             </tr>
948         </table>
949     </body>
950     </html>
951 </p>    
952 </div>
953         </div>
954     </div>
955     </form>
956 </body>
957 </html>

 thanks for Steve Lautenschlager.

and i want to make a ascii code and html code search later.thanks for you read.

转载于:https://www.cnblogs.com/accipiter/archive/2013/01/31/2888245.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值