ultralight-ux / Ultralight

Lightweight, high-performance HTML renderer for game and app developers.
https://ultralig.ht
4.66k stars 195 forks source link

event.key value is "Unidentified" for Escape, NumLock, and for all numpad keys (other than Enter) when numlock is on; event.code is empty string for all keys #504

Open JohnKlenk opened 5 months ago

JohnKlenk commented 5 months ago

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:


<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>