on master help sign in
Expose alt and meta keys, make docs nicer
56b54daEvan Czaplicki
libraries/Keyboard.elm+15−8
@@ -8,7 +8,10 @@ module Keyboard where
8@docs arrows, wasd, directions
8@docs arrows, wasd, directions
9
9
10# Specific Keys
10# Specific Keys
11+The following signals are `True` when the particular key is pressed and `False`
12+otherwise.
13+
11−@docs shift, enter, space, ctrl
14+@docs enter, space, ctrl, shift, alt, meta
12
15
13# General Keypresses
16# General Keypresses
14@docs isDown, keysDown, lastPressed
17@docs isDown, keysDown, lastPressed
@@ -50,19 +53,23 @@ wasd = directions 87 83 65 68
50isDown : KeyCode -> Signal Bool
53isDown : KeyCode -> Signal Bool
51isDown = Native.Keyboard.isDown
54isDown = Native.Keyboard.isDown
52
55
53−{-| Whether the shift key is pressed. -}
56+alt : Signal Bool
57+alt = Native.Keyboard.alt
58+
59+ctrl : Signal Bool
60+ctrl = isDown 17
61+
62+{-| The meta key is the Windows key on Windows and the Command key on Mac.
63+-}
64+meta : Signal Bool
65+meta = Native.Keyboard.meta
66+
54shift : Signal Bool
67shift : Signal Bool
55shift = isDown 16
68shift = isDown 16
56
69
57−{-| Whether the control key is pressed. -}
58−ctrl : Signal Bool
59−ctrl = isDown 17
60−
61−{-| Whether the space key is pressed. -}
62space : Signal Bool
70space : Signal Bool
63space = isDown 32
71space = isDown 32
64
72
65−{-| Whether the enter key is pressed. -}
66enter : Signal Bool
73enter : Signal Bool
67enter = isDown 13
74enter = isDown 13
68
75