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

app.keyboard.isPressed() remains true after switching Tab and coming back to same tab #2855

Closed
saifi476 opened this issue Feb 11, 2021 · 3 comments · Fixed by #2860
Closed

Comments

@saifi476
Copy link

if any key is pressed and the tab is switched, Then the key remains pressed after coming back to the same tab if it's pressed up before coming to this tab.

The first person movement project has this same issue. Here is a link to the project :
https://playcanvas.com/editor/scene/440123

Steps to reproduce:
1- Press any control Key e.g W/UP
2- Change Tab while keeping that key pressed.
3- After changing tab, press up that key and come back to the build (fps) tab.

@Maksims
Copy link
Contributor

Maksims commented Feb 11, 2021

It is due to the way states is stored and updated in engine. When window looses focus, keyup event is not caught by the application, leading to "sticky" state.
Adding support of visibilitychange event, which would set all key states to false - will solve an issue.

@saifi476
Copy link
Author

yes, i read the engine code and it saves all the keys pressed in the object named " this._keymap". So if we somehow delete all the keys from this object on visibilitychange then we can solve this issue.

@saifi476
Copy link
Author

i tried doing adding this line to delete all the key pressed data in engine on detach function (line 68274) but it didn't worked.
this._keymap ={};

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

Successfully merging a pull request may close this issue.

2 participants