News for hackers. Stuff that matters.
Re:Rocket – A Rust game running on WASM by Aissen on Monday December 04, 2017 @07:46AM (#15843411)
I'd love if those to see those web games start to use KeyboardEvent.code https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEve... ; which is much more portable across keymaps and layouts than "key". Unfortunately, it's hindered by slow Edge & Android adoption:

https://caniuse.com/#feat=keyboardevent-code

Re:Rocket – A Rust game running on WASM by mrec on Monday December 04, 2017 @09:03AM (#15843844)
I hadn't seen KeyboardEvent.code before, but after a quick skim I can't see how you'd use it in practice. Being able to recognize physical key positions is nice and all, but how do you map those to the character printed on the key so that you can tell the user what the controls are, before the user has pressed them?

The demo in that MDN page has the help text "Use the WASD (ZQSD on AZERTY) keys to move and steer" which doesn't inspire much confidence if it implies that you need to list controls for every possible keyboard layout and rely on the user knowing what they've got.

Re:Rocket – A Rust game running on WASM by htgb on Monday December 04, 2017 @10:09AM (#15844346)
I'm not sure if it's possible to access the character given the key code (the docs you linked implies it's not), but when we're interested in physical keys, I'd much rather use that nonetheless.

A good way to illustrate the controls could maybe be with an image? The keys on the image could say WASD for all I care, as long as I'm able to see the position of them, which is what matters.

There are similar issues for other things than games. Quite a few programs have `Ctrl + /` or similar as a keyboard shortcut, which is easy on an american keyboard, but on a Swedish one there's no dedicated key for slash (it's `Shift + 7`). The same goes for most symbols except A-Z (I use Swedish QWERTY), they are in other locations and with other modifiers.

Best, of course, is when you can get the character based on the physical key. One example of this is Visual Studio Code, where the shortcut for toggling the console is `Ctrl + Ö`, and presented as such. I assume they defined the shortcut by the physical key (the one to the right of `L` in this case) and presented it by its character.

Re:Rocket – A Rust game running on WASM by mrec on Monday December 04, 2017 @10:52AM (#15844762)
Yeah, in a native app you'd use something like MapVirtualKey [1], but I don't think there's a web equivalent yet.

You still see native apps getting this wrong, though. On a UK keyboard Sublime Text's view menu says that "Show Console" is Ctrl-` (backtick), but the key that actually shows the console is Ctrl-' (single quote). Took me a while to find that.

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...

Re:Rocket – A Rust game running on WASM by KwanEsq on Monday December 04, 2017 @02:21PM (#15846615)
Huh, I'm using SublimeText with a UK keyboard and Ctrl+` shows the console (Ctrl+' just types a ')

That's on Linux though, what are you on, Windows? SublimeText Version 3.0, Build 3143

Re:Rocket – A Rust game running on WASM by mrec on Monday December 04, 2017 @02:39PM (#15846756)
Yeah, Windows 3126. May have been fixed, but definitely not just me: see https://forum.sublimetext.com/search?q=console%20uk