Keys lose track of state when scene paused
If you're holding a key (e.g. holding down after a createCursorKeys() call) and the scene gets paused, that key will remain in its isDown state even when the key is depressed whilst paused.
Here's an example against 3.10.1: https://codepen.io/DannyT/pen/LrwgVe
Hold down key click to pause and switch scene depress down and press space to switch back isDown is maintained and lose your hotdog forever :(
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I have been having this same problem but on changing scenes. A temporary solution for me has been having a clearKeys() function that I call whenever I change scenes:
clearKeys () {
this.input.keyboard.removeKey(Phaser.Input.Keyboard.KeyCodes.ENTER)
this.input.keyboard.removeKey(Phaser.Input.Keyboard.KeyCodes.UP)
this.input.keyboard.removeKey(Phaser.Input.Keyboard.KeyCodes.DOWN)
}
and that fixes the problem, the keys just have to be re-added every time.
I was banging my head around this too.
For anyone having this issue, I found https://photonstorm.github.io/phaser3-docs/Phaser.Input.Keyboard.KeyboardPlugin.html#resetKeys__anchor
Listening for the Phaser.Scenes.Events.PAUSE event in the scene, and then calling resetKeys() in the event handler seems to do the trick.
Thank you for submitting this issue. We have fixed this and the fix 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.