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

Fix hash of keyEvent being added to pressedKeys. #786

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

harry1064
Copy link

When we press a letter, lets say d is key is char value d and hash calculated using keyCodea and key is added to pressed keys. But when without release d, if we press SHIFT key, hash of shift key also being added to pressedKeys. Now, when we release d, it is actually now D hence key value change and when we try to remove new hash, it doesnot exist in pressedKeys and the old hash of d still stays in pressedKeys which was the cause of keyPressed returning true.

fixes #779

When we press a letter, lets say `d` is key is char value `d` and hash calculated using keyCodea and key is added to pressed keys. But
when without release `d`, if we press `SHIFT` key, hash of shift key also being added to pressedKeys.
Now, when we release `d`, it is actually now `D` hence key value change and when we try to remove new hash, it doesnot exist in pressedKeys and the old hash of `d` still stays in pressedKeys which was the cause of keyPressed returning true.
@harry1064
Copy link
Author

Hi @benfry
Hope you are doing well. I saw in your commit that you have included this pull request in todo.txt.
Does it mean you're going to have a look at it when you have time?

@benfry
Copy link
Owner

benfry commented Sep 30, 2023

Yes, went to pull it in but realized that I needed to do additional testing… This is a really messy issue because of the way that different key combinations are posted as events (and there are differences to this between Java2D, OpenGL, and JavaFX as well) so it just needs more thorough work to make sure this is doing what we need. I suspect that this change doesn't fix the problem broadly enough, and want to make sure we have it right before altering something so fundamental.

@harry1064
Copy link
Author

Yes, that make sense.. I was also curious why | key was done in first place. Testing it more thoroughly make sense.

@benfry
Copy link
Owner

benfry commented Sep 30, 2023

Yeah, it's because with any keystroke there may be a combination of key and keyCode, and those vary as different modifiers are applied. It's especially important in this scenario where we're trying to just detect what keys and modifiers are doing.

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 this pull request may close these issues.

keyPressed is true with no keys pressed after specific sequence of SHIFT and any letter key
2 participants