Blog / Home
About
Media Gallery

Welcome
to
Thronic.com

ժʝ_

JavaScript Key Code Reference


This list is quoted from www.javascript.net for reference.

      keydown/keyup event.keyCode                    
Opera   MSIE  Firefox  Safari  Chrome    Key pressed
_________________________________________________________

  8       8       8       8       8      Backspace
  9       9       9       9       9      Tab
 13      13      13      13      13      Enter
 16      16      16      16      16      Shift
 17      17      17      17      17      Ctrl
 18      18      18      18      18      Alt
 19      19      19      19      19      Pause, Break
 20      20      20      20      20      CapsLock
 27      27      27      27      27      Esc
 32      32      32      32      32      Space
 33      33      33      33      33      Page Up
 34      34      34      34      34      Page Down
 35      35      35      35      35      End
 36      36      36      36      36      Home
 37      37      37      37      37      Left arrow
 38      38      38      38      38      Up arrow
 39      39      39      39      39      Right arrow
 40      40      40      40      40      Down arrow
         44      44      44      44      PrntScrn (see below†)
 45      45      45      45      45      Insert
 46      46      46      46      46      Delete
 48-57   48-57   48-57   48-57   48-57   0 to 9
 65-90   65-90   65-90   65-90   65-90   A to Z  
 91      91      91      91      91      WIN Key (Start) 
 93      93      93      93      93      WIN Menu
112-123 112-123 112-123 112-123 112-123  F1 to F12 
144     144     144     144     144      NumLock
145     145     145     145     145      ScrollLock

188     188     188     188     188      , <
190     190     190     190     190      . >
191     191     191     191     191      / ?
192     192     192     192     192      ` ~
219     219     219     219     219      [ { (see below‡)
220     220     220     220     220      \ |
221     221     221     221     221      ] }
222     222     222     222     222      ' "


†In most browsers, pressing the PrntScrn key fires keyup events only. 
‡Key code 219 also corresponds to the Win Key (Start) in older versions of Opera.      


The numeric keypad may produce different keycodes depending on the NumLock state:
All of the above browsers (NumLock On/Off)   Key pressed
__________________________________________________________

            96/45                           Numpad 0 Ins     
            97/35                           Numpad 1 End     
            98/40                           Numpad 2 Down    
            99/34                           Numpad 3 Pg Down 
           100/37                           Numpad 4 Left    
           101/12                           Numpad 5         
           102/39                           Numpad 6 Right   
           103/36                           Numpad 7 Home    
           104/38                           Numpad 8 Up      
           105/33                           Numpad 9 Pg Up   
           106/106                          Numpad *         
           107/107                          Numpad +         
           109/109                          Numpad -         
           110/46                           Numpad . Del     
           111/111                          Numpad /          



Unfortunately, event.keyCode is now deprecated. But I'm leaving the key codes for reference.


Forward, I guess I'll be using code and/or key values. Code values do not respect keyboard layouts, so event.key may be a better option.

Additional links
key locations
key event list


Original Post: Jan 26th, '22 18:50 CET.
Updated: Nov 15th, '22 13:42 CET.

JS
π