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

Removing a Key doesn't remove capturing from KeyboardPlugin #5693

Closed
cyantree opened this issue May 12, 2021 · 4 comments
Closed

Removing a Key doesn't remove capturing from KeyboardPlugin #5693

cyantree opened this issue May 12, 2021 · 4 comments

Comments

@cyantree
Copy link
Contributor

Version

  • Phaser Version: 3.54.0
  • Operating system: Win 10 Pro 20H2
  • Browser:

Description

After registering a key (a letter for example) with capturing enabled Phaser correctly captures the input events. This leads to not being able to type the letter in an input box outside of phaser. This is correct and expected.
However when removing this key, the capturing continues and therefore it still isn't possible to type the letter somewhere outside of Phaser.

I would expect that removing the last registration of a specific key also ends the capturing.
My current workaround is to trigger removeCapture() manually.

Example Test Code

// Register key with capturing enabled by default
const key = scene.input.keyboard.addKey(keyCode);

// Removing the key
scene.input.keyboard.removeKey(key, true);

// Afterwards I still can't use it outside of Phaser

// Removing the capture manually fixes the issue
scene.input.keyboard.removeCapture(key.keyCode);

Additional Information

I would expect that removing the last registration of a specific key also ends the capturing.

I think triggering removeCapture() manually is a workaround because in this case I have to keep track of all Key objects listening to the specific key code.

@samme
Copy link
Contributor

samme commented May 26, 2021

The docs are pretty clear on this, though.

@cyantree
Copy link
Contributor Author

cyantree commented Jun 2, 2021

The docs are pretty clear on this, though.

Could you give me a hint? I read through some pages and didn't find anything obvious regarding this behaviour.

@samme
Copy link
Contributor

samme commented Jun 2, 2021

Sorry, I mean you're doing the right thing, according to the docs. 😃 You have to remove captures manually.

Key captures are global, and they're not really related to Key objects, even though addKey() kind of makes it look that way.

I guess automatically removing captures would be possible. The Input Manager would have to check the registered Keys in each scene.

@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
Projects
None yet
Development

No branches or pull requests

3 participants