elm-lang / keyboard

Global keyboard events in Elm

Home Page:http://package.elm-lang.org/packages/elm-lang/keyboard/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subscription to Keypress State

JoshuaOSHickman opened this issue · comments

I wrote some code to try and track which keys are pressed using this package and the standard JS suggestion:

https://gist.github.com/JoshuaOSHickman/694447f77986bbfb5add80247cd801e5

Doesn't work completely right. For instance, I can press 'a' and then use my mouse to switch focus to another window. Since elm doesn't hear the keyup, even when I return to the window, it appears to be down. I could add in blur checks to empty out the keys-down list, but I'm not 100% sure that's the only scenario where discrepancies could happen. It'd be nice to have in the library either way -- this is 100% how I'm using this package.