[{"name":"Keyboard","comment":" Convenience helpers for working with keyboard inputs.\n\n\n# Msg and Update\n\nUsing Keyboard this way, you get all the help it can provide.\nUse either this approach, or the plain subscriptions and handle the state yourself.\n\n@docs Msg, subscriptions, update\n\n**Note!** If the user presses a key combination that shifts focus, such as `Alt-Tab` or `Ctrl-L`,\nsome keys may get \"stuck\" in the keys list. One solution to this issue is to create a port subscription to the window `blur` events and clearing the entire key list from your model:\n\n    // JavaScript\n    window.onblur = function() { elmApp.ports.blurs.send({}) }\n\n    -- Elm\n    port blurs : (() -> msg) -> Sub msg\n\n    subscriptions : Sub Msg\n    subscriptions =\n        Sub.batch\n            [ Keyboard.subscriptions KeyboardMsg\n            , blurs Blur\n            ]\n\n\n    -- update\n        ...\n        Blur ->\n            { model | pressedKeys = [] }\n        ...\n\n\n## More advanced\n\n@docs updateWithParser, KeyChange, updateWithKeyChange\n\n\n# Key parsers\n\n@docs RawKey, KeyParser\n\n@docs anyKeyUpper, anyKeyOriginal, characterKeyUpper, characterKeyOriginal, modifierKey, whitespaceKey, navigationKey, editingKey, functionKey, phoneKey, mediaKey\n\n\n## Combining key parsers\n\n@docs oneOf\n\n\n# Plain Subscriptions\n\nIf you prefer to only get \"the facts\" and do your own handling, use these\nsubscriptions. Otherwise, you may be more comfortable with the Msg and Update.\n\n@docs downs, ups\n\n\n# Low level\n\n@docs rawValue, eventKeyDecoder\n\n\n# Keyboard keys\n\n@docs Key\n\n","unions":[{"name":"Key","comment":" These are all the keys that have names in `Keyboard`.\n","args":[],"cases":[["Character",["String.String"]],["Alt",[]],["AltGraph",[]],["CapsLock",[]],["Control",[]],["Fn",[]],["FnLock",[]],["Hyper",[]],["Meta",[]],["NumLock",[]],["ScrollLock",[]],["Shift",[]],["Super",[]],["Symbol",[]],["SymbolLock",[]],["Enter",[]],["Tab",[]],["Spacebar",[]],["ArrowDown",[]],["ArrowLeft",[]],["ArrowRight",[]],["ArrowUp",[]],["End",[]],["Home",[]],["PageDown",[]],["PageUp",[]],["Backspace",[]],["Clear",[]],["Copy",[]],["CrSel",[]],["Cut",[]],["Delete",[]],["EraseEof",[]],["ExSel",[]],["Insert",[]],["Paste",[]],["Redo",[]],["Undo",[]],["F1",[]],["F2",[]],["F3",[]],["F4",[]],["F5",[]],["F6",[]],["F7",[]],["F8",[]],["F9",[]],["F10",[]],["F11",[]],["F12",[]],["F13",[]],["F14",[]],["F15",[]],["F16",[]],["F17",[]],["F18",[]],["F19",[]],["F20",[]],["Again",[]],["Attn",[]],["Cancel",[]],["ContextMenu",[]],["Escape",[]],["Execute",[]],["Find",[]],["Finish",[]],["Help",[]],["Pause",[]],["Play",[]],["Props",[]],["Select",[]],["ZoomIn",[]],["ZoomOut",[]],["AppSwitch",[]],["Call",[]],["Camera",[]],["CameraFocus",[]],["EndCall",[]],["GoBack",[]],["GoHome",[]],["HeadsetHook",[]],["LastNumberRedial",[]],["Notification",[]],["MannerMode",[]],["VoiceDial",[]],["ChannelDown",[]],["ChannelUp",[]],["MediaFastForward",[]],["MediaPause",[]],["MediaPlay",[]],["MediaPlayPause",[]],["MediaRecord",[]],["MediaRewind",[]],["MediaStop",[]],["MediaTrackNext",[]],["MediaTrackPrevious",[]]]},{"name":"KeyChange","comment":" The second value `updateWithKeyChange` may return, representing the actual\nchange that happened during the update.\n","args":[],"cases":[["KeyDown",["Keyboard.Key"]],["KeyUp",["Keyboard.Key"]]]},{"name":"Msg","comment":" `Keyboard`'s internal message type.\n","args":[],"cases":[]},{"name":"RawKey","comment":" An unprocessed key value.\n\nUse a `KeyParser` to turn it into something useful.\n\n","args":[],"cases":[]}],"aliases":[{"name":"KeyParser","comment":" A key parser can turn `RawKey`s into meaningful `Key`s for your program.\n","args":[],"type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"}],"values":[{"name":"anyKeyOriginal","comment":" The same as [`anyKeyUpper`](#anyKeyUpper), but with `Character`s in the original case.\n","type":"Keyboard.KeyParser"},{"name":"anyKeyUpper","comment":" This parser tries to match with all the keys I can recognize. `Spacebar` is used for the space\nkey and `Character`s are all uppercase. This parser is used in [`update`](#update).\n\nIf the key doesn't match any of the categories, `Nothing` is returned.\n\n**Note:** If you experience performance issues, you can use [`oneOf`](#oneOf) with some specific parsers.\n\n","type":"Keyboard.KeyParser"},{"name":"characterKeyOriginal","comment":" Returns the character that was pressed, **in the original case**.\n\n**NOTE** There is no reasonable way of actually telling if a certain key is a character or not.\nFor now at least, consider this a Western language focused \"best guess\".\n\nExamples on a US layout:\n\n[A] -> `Just (Character \"a\")`\n\n[Shift] + [A] -> `Just (Character \"A\")`\n\n[Shift] + [1] -> `Just (Character \"!\")`\n\n[Shift] -> `Nothing`\n\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"characterKeyUpper","comment":" Returns the character that was pressed, **always uppercase**.\n\n**NOTE** There is no reasonable way of actually telling if a certain key is a character or not.\nFor now at least, consider this a Western language focused \"best guess\".\n\nExamples on a US layout:\n\n[A] -> `Just (Character \"A\")`\n\n[Shift] + [A] -> `Just (Character \"A\")`\n\n[Shift] + [1] -> `Just (Character \"!\")`\n\n[Shift] -> `Nothing`\n\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"downs","comment":" Subscription for key down events.\n\n**Note** When the user presses and holds a key, there may or may not be many of\nthese messages before the corresponding key up message.\n\n","type":"(Keyboard.RawKey -> msg) -> Platform.Sub.Sub msg"},{"name":"editingKey","comment":" Converts a `RawKey` if it is one of the [editing keys](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Editing_keys).\n\n[Backspace] -> `Just Backspace`\n\n[Enter] -> `Nothing`\n\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"eventKeyDecoder","comment":" Use this with Html keyboard events to retrieve a `RawKey` representing the key\nwhich triggered the event.\n\n    Html.Events.on \"keydown\" eventKeyDecoder\n\n","type":"Json.Decode.Decoder Keyboard.RawKey"},{"name":"functionKey","comment":" Converts a `RawKey` if it is one of the [function keys](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Function_keys).\n\n[F4] -> `Just F4`\n\n[6] -> `Nothing`\n\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"mediaKey","comment":" Converts a `RawKey` if it is one of the [media keys](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Media_keys).\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"modifierKey","comment":" Converts a `RawKey` if it is one of the [modifier keys](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Modifier_keys).\n\n[Alt] -> `Just Alt`\n\n[Tab] -> `Nothing`\n\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"navigationKey","comment":" Converts a `RawKey` if it is one of the [navigation keys](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Navigation_keys).\n\n[ArrowLeft] -> `Just ArrowLeft`\n\n[A] -> `Nothing`\n\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"oneOf","comment":" Turn any `RawKey` into a `Key` using the processing functions (`modifierKey`, `whitespaceKey`,\netc.) provided. If the key doesn't match any of the categories, `Nothing` is returned.\n","type":"List.List Keyboard.KeyParser -> Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"phoneKey","comment":" Converts a `RawKey` if it is one of the [phone keys](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Phone_keys).\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"rawValue","comment":" Get the original string value of the `RawKey`.\n","type":"Keyboard.RawKey -> String.String"},{"name":"subscriptions","comment":" The subscriptions needed for the \"Msg and Update\" way.\n","type":"Platform.Sub.Sub Keyboard.Msg"},{"name":"update","comment":" Use this to have the list of keys update.\n\nThis will give you all the keys I can recognize.\n\n  - If you encounter sluggish performance and need to optimize your program,\n    try [`updateWithParser`](#updateWithParser).\n  - If you need to know exactly what changed just now, have a look\n    at [`updateWithKeyChange`](#updateWithKeyChange).\n\n","type":"Keyboard.Msg -> List.List Keyboard.Key -> List.List Keyboard.Key"},{"name":"updateWithKeyChange","comment":" This alternate update function answers the question: \"Did the pressed down\nkeys in fact change just now?\"\n\nYou might be wondering why this is a `Maybe KeyChange` &ndash; it's because\n`keydown` events happen many times per second when you hold down a key. Thus,\nnot all incoming messages actually cause a change in the model. Also, you will\nonly get updates for the keys that match your `KeyParser`.\n\n","type":"Keyboard.KeyParser -> Keyboard.Msg -> List.List Keyboard.Key -> ( List.List Keyboard.Key, Maybe.Maybe Keyboard.KeyChange )"},{"name":"updateWithParser","comment":" A more advanced version of `update`. Provide it with a smaller `KeyParser` than `anyKey` and\nit will perform a little bit faster.\n","type":"Keyboard.KeyParser -> Keyboard.Msg -> List.List Keyboard.Key -> List.List Keyboard.Key"},{"name":"ups","comment":" Subscription for key up events.\n","type":"(Keyboard.RawKey -> msg) -> Platform.Sub.Sub msg"},{"name":"whitespaceKey","comment":" Converts a `RawKey` if it is one of the [whitespace keys](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Whitespace_keys).\n\n[Tab] -> `Just Tab`\n\n[Alt] -> `Nothing`\n\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"}],"binops":[]},{"name":"Keyboard.Arrows","comment":" Arrow keys and WASD get special treatment using the functions in this module. This is particularly useful for games.\n\n@docs Arrows, arrows, wasd, Direction, arrowsDirection, wasdDirection, arrowKey\n\n","unions":[{"name":"Direction","comment":" Type representation of the arrows.\n","args":[],"cases":[["North",[]],["NorthEast",[]],["East",[]],["SouthEast",[]],["South",[]],["SouthWest",[]],["West",[]],["NorthWest",[]],["NoDirection",[]]]}],"aliases":[{"name":"Arrows","comment":" Record type used for `arrows` and `wasd`.\nBoth `x` and `y` can range from `-1` to `1`, and are `0` if no keys are pressed.\n\nFor example:\n\n  - `{ x = 1, y = 0 }` means to the right\n  - `{ x = 0, y = -1 }` means down\n\n","args":[],"type":"{ x : Basics.Int, y : Basics.Int }"}],"values":[{"name":"arrowKey","comment":" A key parser for just the Arrow keys and W, A, S, D. They are always uppercase.\n\n[ArrowLeft] -> `Just ArrowLeft`\n\n[A] -> `Character \"A\"`\n\n[B] -> `Nothing`\n\n","type":"Keyboard.RawKey -> Maybe.Maybe Keyboard.Key"},{"name":"arrows","comment":" Gives the arrow keys' pressed down state as follows:\n\n    arrows []                      --> { x = 0, y = 0 }\n\n    arrows [ ArrowLeft ]           --> { x = -1, y = 0 }\n\n    arrows [ ArrowUp, ArrowRight ] --> { x = 1, y = 1 }\n\n    arrows [ ArrowDown, ArrowLeft, ArrowRight ]\n                                   --> { x = 0, y = -1 }\n\n","type":"List.List Keyboard.Key -> Keyboard.Arrows.Arrows"},{"name":"arrowsDirection","comment":" Gives the arrow keys' pressed down state as follows:\n\n    arrowsDirection []\n    --> NoDirection\n\n    arrowsDirection [ ArrowLeft ]\n    --> West\n\n    arrowsDirection [ ArrowUp, ArrowRight ]\n    --> NorthEast\n\n    arrowsDirection [ ArrowDown, ArrowLeft, ArrowRight ]\n    --> South\n\n","type":"List.List Keyboard.Key -> Keyboard.Arrows.Direction"},{"name":"wasd","comment":" Similar to `arrows`, gives the W, A, S and D keys' pressed down state.\n\n    wasd []\n    --> { x = 0, y = 0 }\n\n    wasd [ Character \"A\" ]\n    --> { x = -1, y = 0 }\n\n    wasd [ Character \"W\", Character \"D\" ]\n    --> { x = 1, y = 1 }\n\n    wasd [ Character \"A\", Character \"S\", Character \"D\" ]\n    --> { x = 0, y = -1 }\n\n","type":"List.List Keyboard.Key -> Keyboard.Arrows.Arrows"},{"name":"wasdDirection","comment":" Similar to `arrows`, gives the W, A, S and D keys' pressed down state.\n\n    wasdDirection []\n    --> NoDirection\n\n    wasdDirection [ Character \"A\" ]\n    --> West\n\n    wasdDirection [ Character \"W\", Character \"D\" ]\n    --> NorthEast\n\n    wasdDirection [ Character \"A\", Character \"S\", Character \"D\" ]\n    --> South\n\n","type":"List.List Keyboard.Key -> Keyboard.Arrows.Direction"}],"binops":[]}]