combokeys icon indicating copy to clipboard operation
combokeys copied to clipboard

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

Open ContraTrouble opened this issue 3 years ago • 0 comments

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!

ContraTrouble avatar Dec 26 '22 14:12 ContraTrouble