Open JohnKlenk opened 5 months ago
The event.key value is "Unidentified" for Escape and NumLock, and for numpad keys other than Enter when numlock is on.
event.key
And for apparently every key, event.code is an empty string.
event.code
Sample code:
<body> <h1>Press a key</h1> <div id="output"></div> <script> document.addEventListener('keydown', function(event) { document.getElementById('output').innerHTML = ` key: ${event.key}<br> code: ${event.code}<br> which: ${event.which}<br> keyCode: ${event.keyCode}<br> `; }); </script> </body> </html>
The
event.key
value is "Unidentified" for Escape and NumLock, and for numpad keys other than Enter when numlock is on.And for apparently every key,
event.code
is an empty string.Sample code: