Arrow keys and WASD get special treatment using the functions in this module. This is particularly useful for games.
Gives the arrow keys' pressed down state as follows:
arrows [] --> { x = 0, y = 0 }
arrows [ ArrowLeft ] --> { x = -1, y = 0 }
arrows [ ArrowUp, ArrowRight ] --> { x = 1, y = 1 }
arrows [ ArrowDown, ArrowLeft, ArrowRight ]
--> { x = 0, y = -1 }Similar to arrows, gives the W, A, S and D keys' pressed down state.
wasd []
--> { x = 0, y = 0 }
wasd [ Character "A" ]
--> { x = -1, y = 0 }
wasd [ Character "W", Character "D" ]
--> { x = 1, y = 1 }
wasd [ Character "A", Character "S", Character "D" ]
--> { x = 0, y = -1 }Type representation of the arrows.
Gives the arrow keys' pressed down state as follows:
arrowsDirection []
--> NoDirection
arrowsDirection [ ArrowLeft ]
--> West
arrowsDirection [ ArrowUp, ArrowRight ]
--> NorthEast
arrowsDirection [ ArrowDown, ArrowLeft, ArrowRight ]
--> SouthSimilar to arrows, gives the W, A, S and D keys' pressed down state.
wasdDirection []
--> NoDirection
wasdDirection [ Character "A" ]
--> West
wasdDirection [ Character "W", Character "D" ]
--> NorthEast
wasdDirection [ Character "A", Character "S", Character "D" ]
--> South
Record type used for
arrowsandwasd. Bothxandycan range from-1to1, and are0if no keys are pressed.For example:
{ x = 1, y = 0 }means to the right{ x = 0, y = -1 }means down