Free online utilities to convert,
calculate, and transform.
 

JS Key Event Codes

Javascript assigns a numeric code to every key on a keyboard, including ones that control programs and interfaces.

Press any key to display its code:

Input:
KeyCode: [press any key]
KeyName: [press any key]

Here is a table that contains the values from event.which.

KeyCode Number with key name
Code Key Code Key
8 Backspace 85 Letter U
9 Tab 86 Letter V
13 Enter 87 Letter W
16 Shift 88 Letter X
17 Ctrl 89 Letter Y
18 Alt 90 Letter Z
19 Break 91 Left command key
20 Caps lock 92 Right command key
27 Escape 93 Select key
32 Space 96 Numpad 0
33 Page up 97 Numpad 1
34 Page down 98 Numpad 2
35 End 99 Numpad 3
36 Home 100 Numpad 4
37 Left arrow 101 Numpad 5
38 Up arrow 102 Numpad 6
39 Right arrow 103 Numpad 7
40 Down arrow 104 Numpad 8
45 Insert 105 Numpad 9
46 Delete 106 Multiply *
48 Numner 0 107 Add +
49 Numner 1 109 Subtract -
50 Numner 2 110 Decimal point .
51 Numner 3 111 Divide /
52 Numner 4 112 F1
53 Numner 5 113 F2
54 Numner 6 114 F3
55 Numner 7 115 F4
56 Numner 8 116 F5
57 Numner 9 117 F6
65 Letter A 118 F7
66 Letter B 119 F8
67 Letter C 120 F9
68 Letter D 121 F10
69 Letter E 122 F11
70 Letter F 123 F12
71 Letter G 144 Num lock
72 Letter H 145 Scroll lock
73 Letter I 186 Colon
74 Letter J 187 Equal sign
75 Letter K 188 Comma
76 Letter L 189 Dash
77 Letter M 190 Period
78 Letter N 191 Forward slash
79 Letter O 192 Grave accent
80 Letter P 219 Open bracket
81 Letter Q 220 Back slash
82 Letter R 221 Close braket
83 Letter S 222 Single quote
84 Letter T

JavaScript Key Event Codes

JavaScript key event codes, also known as key codes or key values, are numeric values assigned to each key on a keyboard. They are used to identify which key has been pressed or released during a keyboard event.

Key event codes are commonly used in web development to add interactivity and user input to web pages. For example, you might use key event codes to create a keyboard shortcut that performs a certain action when the user presses a specific key combination.

Key event codes are represented by numerical values in the range of 0-255, and each value corresponds to a specific key on a keyboard. They can be accessed using the keyCode property of the KeyboardEvent object, which is passed as an argument to a key event listener function.

Here are a few examples of common key event codes:

  • 13: "Enter key"
  • 32: "Space bar"
  • 65: Letter "A"
  • 48: Number "0"

By using key event codes in combination with event listeners, you can create powerful keyboard-driven interactions that make your web pages more engaging and user-friendly. For example, the key event captured in webpage uses a variation of the following JavaScript event handler:

document.addEventListener("keydown",
  function(event){
    console.log(event.which);
  })

Knowing the key number or keycode in JavaScript Keyboard Events provides developers with a powerful tool to create responsive and user-friendly web applications.


Related Utilities


Feedback

Help us improve this page by providing feedback:


Share with