ultralight-ux / Ultralight

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

KeyboardEvent.key is always an empty string #332

Closed dbartussek closed 2 years ago

dbartussek commented 3 years ago

I can't find any documentation whether this is intentional or not.

This example HTML

<html>
  <head>
    <script>
        document.addEventListener('keydown', event => {
            if (!event.repeat) {
                document.getElementById("example").innerHTML += `keydown, key ${event.key}, which ${event.which}, whichCharCode ${String.fromCharCode(event.which)}<br>`;
            }
        });
        document.addEventListener('keypress', event => {
            if (!event.repeat) {
                document.getElementById("example").innerHTML += `keypress, key ${event.key}, which ${event.which}, whichCharCode ${String.fromCharCode(event.which)}<br><br>`;
            }
        });
    </script>
  </head>
  <body>
    <div id="example"></div>
  </body>
</html>

Produces this output in Ultralight

keydown, key , which 65, whichCharCode A
keypress, key , which 97, whichCharCode a

In Firefox, it produces

keydown, key a, which 65, whichCharCode A
keypress, key a, which 97, whichCharCode a
adamjs commented 3 years ago

Thanks for the report! I can reproduce, will fix.

adamjs commented 2 years ago

This is fixed in latest trunk.