Retaining Keyboard Inputs with Modal Scenes

I am encountering an issue when going from my main game scene, to a modal scene. This modal scene is used as a confirmation scene to reset the game and return to the title scene. If the player holds the ‘Q’ and ‘W’ keys for 3 seconds I run the modal scene, bring it to the top, and pause my game scene. Within the modal scene I want to use ‘Q’ or ‘W’ as input to select yes or no if you want to return to the title scene. If the player selects no I want them to resume the main game scene. I was wondering if anyone knows how to manage this, because I keep losing functionality of ‘Q’ and ‘W’ once I return back to the main game scene from the modal. If posting pictures of my functions would help just let me know and I can upload my code for getting to the modal scene and returning. Thanks for any help or advice on this!

I can think of different reasons that would cause this, but it’s hard to say for certain without seeing any code. The functions which open and close the modal should be sufficient to determine whether the modal scene is shut down properly and whether the game scene is resumed. It would also be nice to know which Phaser version you’re using, just in case it’s an older one.

I am using Phaser version 3.16.1.
Here is how I declare the keys within the my game scene, inside the create function.
initializeKeys
Here is how I transition from the game scene to the confirmation scene.
toModalSceneFromGame
Here is how I switch from the confirmation scene back to the game scene.
toGameSceneFromModal

So after a bunch of debugging today I realized that when I switch scenes the keys are being held down, which is causing the keyboard input to be “locked” and carry over to the next scene. I even try to keyQ.enabled = false before switching scenes and that also does not work. Not sure if any of this helps or not.

Update: so I got it working now, I was using the same global variable keyQ and keyW within both scenes which seemed to be my issue. Instead I created two new variables within the confirmation window and initialized the keys Q and W to them. After doing this it seemed to solve it. :smile: