Convenience helpers for working with keyboard inputs.
Get the full list of keys that are currently pressed down.
Gives the arrow keys' pressed down state as follows:
{ x = 0, y = 0 } when pressing no arrows.{ x =-1, y = 0 } when pressing the left arrow.{ x = 1, y = 1 } when pressing the up and right arrows.{ x = 0, y =-1 } when pressing the down, left, and right arrows (left and right cancel out).Similar to arrows, gives the W, A, S and D keys' pressed down state.
{ x = 0, y = 0 } when pressing none of W, A, S and D.{ x =-1, y = 0 } when pressing A.{ x = 1, y = 1 } when pressing W and D.{ x = 0, y =-1 } when pressing A, S and D (A and D cancel out).Type representation of the arrows.
Gives the arrow keys' pressed down state as follows:
None when pressing no arrows.West when pressing the left arrow.NorthEast when pressing the up and right arrows.South when pressing the down, left, and right arrows (left and right cancel out).Similar to arrows, gives the W, A, S and D keys' pressed down state.
None when pressing none of W, A, S and D.West when pressing A.NorthEast when pressing W and D.South when pressing A, S and D (A and D cancel out).The internal representation of Keyboard.Extra. Useful for type annotation.
The message type Keyboard.Extra uses.
You will need to add this to your program's subscriptions.
Use this to initialize the component.
You need to call this to have the component update.
A Json.Decoder for grabbing event.keyCode and turning it into a Key
import Json.Decode as Json
onKey : (Key -> msg) -> Attribute msg
onKey tagger =
on "keydown" (Json.map tagger targetKey)These are all the keys that have names in Keyboard.Extra.
Convert a key code into a Key.
Convert a Key into a key code.
Check the pressed down state of any
Key.