There is a Keyboard package which might work for you -> 'This library lets 
you listen to global keyboard events' 

http://package.elm-lang.org/packages/elm-lang/keyboard/1.0.1/Keyboard

although I seem to remember that I did have problems with event propagation 
when I was playing with it (in that I couldn't stop them from bubbling up 
the DOM).


On Thursday, February 2, 2017 at 7:23:31 AM UTC, Lyle Kopnicky wrote:
>
> Hi folks,
>
> I'm having trouble detecting keypresses in Elm 0.18. The only examples I 
> can find are old ones that use Signals. There are no examples in the Elm 
> Architecture Tutorial. The Html.Events module documentation shows a piece 
> of the puzzle with the example for onKeyUp.
>
> Heres a gist with the code: 
> https://gist.github.com/anonymous/5f54c2b2c8fb42a31d4ae37058a72e2a
>
> You can ignore the KaTeX import - that's not used at the moment.
>
> It compiles and runs, but the circle just sits there. I have know way of 
> knowing if it's detecting my keypresses. I thought that by putting the 
> event handler on the outer div, it would intercept keypresses. I didn't 
> have any way of adding handler to the svg element.
>
> BTW I also tried 'keyup' instead of 'keypress', and I tried making it 
> generate the MoveRight message for any key, just to make sure it wasn't bad 
> key code problem.
>
> Do I need to somehow attach the keypress handler to the document instead? 
> Perhaps I need to use a subscription? I'm not finding any guidance in the 
> docs. Any help would be appreciated.
>
> Thanks,
> Lyle
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to