3 ms·
The big pitfall in the api of browser and keyboard is there is not a method to get the status (keys pressed) of the keyboard. I know that it is about security
by mdtrooper 3y ago
The big pitfall in the api of browser and keyboard is there is not a method to get the status (keys pressed) of the keyboard.
I know that it is about security stuff, but for the games in js is a bad situation when the canvas lost the focus and the keys pressed change.
- Waterluvian 3y agoI fought with this so much today. Our robots can be driven remotely via a web app. But there’s ways to accidentally get buttons stuck down because keyup is never guaranteed and you can’t get key state. Two cases: holding down forward key and blur the tab, or open contextmenu. There’s workarounds of course. But it’s comical spending so much time on something so simplistic.
- pininja 3y agoThis might be an appropriate use for the Gamepad API which can be queried on every animation frame for a button’s state. https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API...
- Waterluvian 3y agoThe Gamepad API is fun, but we’re not trying to implement a gamepad.
- dataflow 3y agoHow is this a security issue?
- Retr0id 3y agoYou can handle the onblur event and use it to clear all pressed keys.