Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Losing focus keeps cursor key as pressed #4134

Closed
DavyKoravand opened this issue Oct 29, 2018 · 1 comment
Closed

Losing focus keeps cursor key as pressed #4134

DavyKoravand opened this issue Oct 29, 2018 · 1 comment

Comments

@DavyKoravand
Copy link

Version

  • Phaser Version: 3.15.1
  • Operating system: Windows 10
  • Browser: All

Description

When the game loses focus while a key is pressed, that key will continue to be pressed according to Phaser even though the user has lifted their finger. To make matters worse, when the game regains focus, that key will remain to be pressed according to Phaser until it is pressed again.

Example Test Code

const cursors = scene.input.keyboard.createCursorKeys();
const LEFT_KEY = cursors.left.isDown;
const RIGHT_KEY = cursors.right.isDown;
const UP_KEY = cursors.up.isDown;
const DOWN_KEY = cursors.down.isDown;

Additional Information

Reproduction steps:

  • Hold DOWN
  • Lose focus (e.g. by opening the developer console or clicking on a different window)
  • Regain focus, and DOWN will remain to be pressed until you press it again

Suggested fix:

  • scene.input.keyboard.createCursorKeys() should not return true for any key if the window is not focused (can be detected using the lose focus callback)
@photonstorm
Copy link
Collaborator

Thank you for submitting this feature request. We have implemented this and the feature has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants