Skip to content

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