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

Reset pressed keys when reseting modifiers #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EtienneLem
Copy link

@EtienneLem EtienneLem commented Sep 12, 2017

aka when re-focusing window.

Teh problem

In our app we use key.isPressed(KEYS.ALT) to detect when alt is pressed to execute some alternate-power-user-hidden actions. 💪

We noticed that very often alt is being detected as pressed while it was in fact: Not pressed. 😱

Teh steps

This can be reproducible quite easily (especially when alt is being used for Alfred or Spotlight):

  • Focus page/app
  • Press and hold alt
  • Unfocus page/app (can be by focusing dev tools)
  • Release alt
  • Focus page/app
  • console.log(key.isPressed(18), key.getPressedKeyCodes()). 💥

In long-lived apps, you’ll notice that key.getPressedKeyCodes() tends to get bigger and bigger. The only way to reset it is finding and pressing all the keys present in the array. 😅

Teh fix

Reseting _downKeys on resetModifiers fixes that. 🤘

I can’t really think of a false-positive or unexpected behaviour since key.isPressed don’t work for keys pressed prior to focusing page/app.

aka when re-focusing window
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

Successfully merging this pull request may close these issues.

1 participant