Press any key

to instantly inspect Javascript KeyboardEvent properties and grab the code snippet.

?
Code
Ctrl
Alt
Shift
Meta
event.key
-
The physical key pressed. Use this!
event.code
-
The physical location on keyboard. Always the same regardless of layout.
event.which
-
Deprecated. Avoid using.
event.keyCode
-
Deprecated. Avoid using.

Event Listener Snippet

window.addEventListener('keydown', (e) => {
  if (e.key === 'a') {
    // do something
  }
});

Session History

Location

0

General keys = 0, Left-side modifier = 1, Right-side modifier = 2, Numpad = 3

`
1
2
3
4
5
6
7
8
9
0
-
=
Backspace
Tab
Q
W
E
R
T
Y
U
I
O
P
[
]
\
Caps
A
S
D
F
G
H
J
K
L
;
'
Enter
Shift
Z
X
C
V
B
N
M
,
.
/
Shift
Ctrl
Alt
Meta
Space
Meta
Alt
Ctrl
Copied