RobertWHurst / Keystrokes

Keystrokes as an easy to use library for binding functions to keys and key combos. It can be used with any TypeScript or JavaScript project, even in non-browser environments.
MIT License
158 stars 6 forks source link

Bug with self releasing keys feature #7

Closed colinsullivan closed 1 year ago

colinsullivan commented 1 year ago

Describe the bug Crash when using self-releasing keys feature

To Reproduce Steps to reproduce the behavior: Use self-releasing keys with a key combo Note error in console

Expected behavior Feature works

Additional context

The issue is here:

https://github.com/RobertWHurst/Keystrokes/blob/master/packages/keystrokes/src/keystrokes.ts#L435

Note the objects in _activeKeyPresses are already in the form of { key: "z", event: { ... } }. Then the crash occurs here:

https://github.com/RobertWHurst/Keystrokes/blob/master/packages/keystrokes/src/keystrokes.ts#L340

Because event.key.toLowerCase is undefined

colinsullivan commented 1 year ago

Got a test , not sure how to fix it though...

The _tryReleaseSelfReleasingKeys method seems like it has additional problems, maybe the feature hasn't been worked through fully yet?

RobertWHurst commented 1 year ago

Thanks for reporting this issue. Let me take a look at your PRs. 🍻

RobertWHurst commented 1 year ago

Closing as I've merged #10 but we can continue the conversation if you have feedback.