Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFeature request: continuous keydown events #551
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
halfzebra
Apr 10, 2016
Contributor
You can achieve that by doing something like this, along with filtering for required key codes:
import Keyboard
import Signal
import Time
import Debug
import Graphics.Element exposing (show)
main =
Keyboard.keysDown
|> Signal.sampleOn (Time.fps 30)
|> Signal.map show
Does that really require a core feature?
|
You can achieve that by doing something like this, along with filtering for required key codes:
Does that really require a core feature? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jinjor
Apr 11, 2016
Contributor
Thanks, but I need different behavior. When some key is keeping pressed, The first event is fired immediately and the rest are fired after some interval. Like this:
a.......aaaaaaaaaaaaaaa
Also, I read the source and found the down state is made by filtering original events. I think it's more natural to use the original events than to reproduce new events.
|
Thanks, but I need different behavior. When some key is keeping pressed, The first event is fired immediately and the rest are fired after some interval. Like this: a.......aaaaaaaaaaaaaaa Also, I read the source and found the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Warry
Apr 11, 2016
Repeating keys can be retrieved with keyup, but the core only supports keydown. I agree with @jinjor that it should be the developer's choice and should be available there.
Maybe we should expose document's events withOptions, just like for Html, where we can listen to an event by giving a string and a decoder.
Warry
commented
Apr 11, 2016
|
Repeating keys can be retrieved with Maybe we should expose |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
I think this is solved in |
jinjor commentedApr 5, 2016
Currently
Keyboardmodule does not have API for continuous keydown events.Keyboard.isDownis fired only when value is changed, but I sometimes need many events when I keep keys pressing.For example, I am implementing Undo/Redo triggered by
ctrl+Z/ctrl+Y. I usually undo 100+ steps by keepctrl+Zpressing, but this feature cannot be implemented using current API.