← Back to context

Comment by Waterluvian

5 hours ago

I think they just need to use KeyboardEvent.code to design for key location, not key character.

They do, which is why WASD (or whatever the positional equivalent in your layout is) work despite the text saying to press ZQSD. This only solves the input though, it doesn't let the page know ahead of time what letter it should tell you to press for those 4 positional inputs.

Chromium based browsers support navigator.keyboard.getLayoutMap() to tackle this exact problem. Safari and Firefox do not due to concerns over fingerprinting. Still, it wouldn't hurt to add this second half for those users https://caniuse.com/?search=navigator.keyboard.getLayoutMap%...