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

ALT CTRL 1 works, but ALT 1 and CTRL 1 do not. #149

Open
EdwardGioja opened this issue Apr 20, 2019 · 5 comments
Open

ALT CTRL 1 works, but ALT 1 and CTRL 1 do not. #149

EdwardGioja opened this issue Apr 20, 2019 · 5 comments

Comments

@EdwardGioja
Copy link

This is just one example. I'm having the issue with a number of keys, like other numbers and "K".

I am NOT using the number keypad.

I am using prevent_repeat, is_unordered, is_exclusive, is_solitary, and the "on_keydown" function.
is_exclusive is strange... for instance, on CTRL1, if I use prevent_default, I get nothing. If I don't use prevent_default, it changes to the first tab (the default use of CTRL1).

The debugger shows that they are registered:
image

@EdwardGioja
Copy link
Author

I just figured out the issue. If I have a CTRL1 and an ALT1, both work. I can not, however, have an ALT+CTRL+1 and an ALT+1 or a CTRL+1.

I can work around this, although it does cut down on the number of "hot keys" my users can create. It is something you may want to look at.

BTW, this is behavior in the last version of Firefox and Edge

@dmauro
Copy link
Owner

dmauro commented Apr 21, 2019

It's hard to say without seeing the other combos, but it sounds like you're probably bumping into this specific detail of is_solitary:

When we set is_exclusive to true, we will not call the callbacks for any combos that are also exclusive and less specific.

So in your follow-up combo, for instance. If you have Alt+Ctrl+1 and Alt+1 and they're solitary, Alt+1 could never fire because it would always be trying to fire Alt+Ctrl+1. Does that answer your question?

@EdwardGioja
Copy link
Author

EdwardGioja commented Apr 21, 2019 via email

@dmauro
Copy link
Owner

dmauro commented Apr 28, 2019

Yeah, the crux of the problem is, with the way the system is built, when the player presses ALT+1, we're then either a) waiting for CTRL to also be pressed to fire the more complex match, or b) fire ALT+1 and then risk firing both if they then pressed CTRL.

This could be avoided if we then invalidated those keys that matched the ALT+1, but it would still be a bit of a user problem because then you'd have to make sure to hit CTRL first if you wanted to do ALT+1+CTRL so that you didn't accidentally trigger ALT+1. Another route you could go is to do some sort of timing where we match the combo after a set amount of ms with no other inputs, which might just be the best option, at least for what you're looking for, but when I first designed this, I was trying to avoid timing stuff (except for the sequences) because it didn't make sense for my use case.

tl;dr It's kind of a design problem that hits the boundaries of how I designed this system to work. FWIW there are a lot of other key-command JS solutions out there and I'd be willing to bet there's one that works better for your use case. Good luck!

@EdwardGioja
Copy link
Author

EdwardGioja commented Apr 29, 2019 via email

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

2 participants