0 votes

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
https://www.newgrounds.com/portal/view/project/1811360
and itch.io here
https://3p0ch.itch.io/testing-mouse-capture-in-godot?secret=mATfheDxatid2xx5xsh4XRIhJ0
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.

Godot version 3.4 stable
in Engine by (29 points)

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.