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

Keyboard handler is triggered multiple times. #699

Open
svdsande opened this issue Nov 22, 2022 · 0 comments
Open

Keyboard handler is triggered multiple times. #699

svdsande opened this issue Nov 22, 2022 · 0 comments
Labels

Comments

@svdsande
Copy link

Due to the fact that both key and code are checked when determining if a key is triggered, a keyboard handler could be called multiple times.

The following function will be called twice when pressing NumpadEnter

@onKey('Enter')
@onKey('NumpadEnter')
onEnterOrNumpadEnterDown(e) {
  this.args.onTrigger(e);
}

The reason for this behavior is the fact that in this scenario event.code is equal to NumpadEnter but event.key is equal to Enter Therefore when iterating over all keyboard handlers @onKey('Enter') will also be called since event.key will match. I found an older pull request #135 in which the option is discussed the specify a mode, this would enable developers to explicitly specify state if the they want to match based on key or code. Having this option would solve the problem at hand, but I understand that this proposal didn't make it in the final API design. But would it be possible to combine @onKey('Enter') and @onKey('NumpadEnter')? Let me know if I could help in any way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants