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

Binding multiple combinations does not work as expected (or the callback needs an extra parameter) #72

Open
ContraTrouble opened this issue Dec 26, 2022 · 0 comments

Comments

@ContraTrouble
Copy link

ContraTrouble commented Dec 26, 2022

Let's say I have the letters "a", "b", and "c" and want to bind a different callback for each unique combination on keyup (think a "chord" in music where you press multiple keys at the same time).

For simplicity let's have only 3 combinations:

  • ["a", "b"] (the one I will press)
  • ["a", "c"]
  • ["c", "b"]

If I bind the above 3 sequences, when I press and hold "a" and "b", the callback will be called twice, for:

  • ["a", "c"] - it seems to pick a combination where the 1st letter matches the 1st letter in the bound sequence
  • ["c", "b"] - ditto - picks a combination where the 2nd letter matches the 2nd letter in the bound sequence

What I need is for it to trigger only for ["a", "b"] which are the 2 keys I actually pressed.

In the title of the issue, when I said "or the callback needs an extra parameter" I meant that instead of just passing the keyboard event as an argument, the library could pass the actual sequence (e.g. ["a", "c"]), and then I'd be able to filter out the "bogus" combinations. This will not fix my issue (now), because as I explained, the callback for the ["a", "b"] combination that I'm expecting to be called is not called at all.

I'm not in a hurry (can wait a couple of months), but if you're too busy or don't recognize this as something that's needed, please comment on the issue, and I'll either fork it, or create a PR (if you think that's useful).

Thanks!

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

No branches or pull requests

1 participant