Closed beauwest closed 8 years ago
This seems to be working as expected because it's a toggle button. If you want to do any logic using a lock key, you'll have to get more explicit in the key bindings using down and up events.
Sorry, I think I'm missing something. The primary issue is with is_solitary: true
hotkeys. Since it still sees "caps" as down.
When you say that I'd have to get more explicit to avoid this, what do you mean?
Do you have a code example of what you're trying to do?
Okay, a couple thoughts:
My current work-around is to register a second combo listener for any is_solitary
hotkeys. I use a registration function for our web app so it makes it easy to do, however, it nearly doubles the amount of listeners in the system. I'm sure that has a performance impact. I implemented this work-around until it can be fixed at the library level.
My initial thought would be to implement another option to Keypress, something like normalize_toggle_keys
(default to false
). When normalize_toggle_keys
is true
, it would behave like your first option. Basically it would just prevent toggle/locking keys from being added to the _keys_down
array. Or have the check for is_solitary
ignore those types of keys.
The only reason I'd hesitate to change the behavior entirely, is to not break any existing code out there that implements the current caps
behavior. You'd have a better feel for the affects of that though.
I don't think it'd be a good idea to have it persist through refreshes. And I agree that it's scary to have locking keys fire "extra" events.
By the way, sometimes bug reports can come across as harsh when it's a project you've worked hard on. I just wanted to take a moment to say I love Keypress. It's made the web app I'm working on a breeze. Thanks for all your work on it. 👏
Yeah, I think that's a great idea! I'm open to pull requests, but otherwise I'll try to dig into this when I get the chance (might not be soon 😬 ). And thanks for the encouraging words. I'm really glad to hear this project has been helpful for you 😄
Pull Request #115
I've only tested on a Mac, however, the
caps
indicator remains in the_keys_down
array when turned on. This results inis_solitary
key combinations not being able to be triggered sincecaps
is down.This happens at the OS level, as you can see by triggering Caps Lock on this page: http://www.asquare.net/javascript/tests/KeyCode.html – There is a
keyDown
event, but nokeyUp
event until the key is pressed again.