|Attention||Topic was automatically imported from the old Question2Answer platform.|
I’ve made an HTML5 game and uploaded it to a hosting site (NewGrounds) and found that if I interact with things other than the game and then go back to the game canvas it’s very unreliable about whether it regains capture of keyboard input.
The minimal test build linked below (originally made for a different issue) can be used to demonstrate this issue too. If you move your mouse around the game canvas, it will show the relative mouse motion so you know the game is detecting the mouse. When I first start the game and click so it captures the mouse, it also captures keyboard input so the up/down arrows and space won’t scroll the webpage. But if I right click to release the mouse and then give the parent webpage focus by clicking on stuff or highlighting text (to mimic a player reading the Author Comments or giving the game a score or leaving a review etc.) and then go back to the game canvas it will reliably detect and be able to re-capture the mouse if I click but it only sometimes (less than half the time) re-captures keyboard input. With my actual game the player won’t move if it fails to re-capture, and in this minimal bug reproduction build you can see it because the up/down arrows and space end up scrolling the webpage around instead of being captured by the Godot game.
I’ve tested it on both NewGrounds here
and itch.io here
and they both have that behavior in Chrome and Firefox. Games made with different engines hosted by those sites don’t.
I’d like to check if other people are seeing the same problem with key capture in hosted HTML5 games, or if it’s just an issue with my computer (Windows 11 in Chrome and Firefox)? If other people are also seeing it I’ll report it on GitHub.
I can’t replicate, it seems to work fine for me no matter what I do. I’ve never had a problem with capturing input on html5 so I’m genuinely no sure what you’re experiencing.
DaddyMonster | 2022-01-16 19:39