Last active
June 30, 2018 23:43
-
-
Save Chadtech/baba5b5d01ceb320b00d41d5464fe1b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Json.Decoder as Decode | |
| import Html.Events exposing (keyCode, on) | |
| onEnter : msg -> Attribute msg | |
| onEnter msg = | |
| on "keydown" (keyCode |> Decode.andThen (enterDecoder msg)) | |
| enterDecoder : msg -> Int -> Decoder msg | |
| enterDecoder msg keyCode = | |
| case keyCode of | |
| 13 -> | |
| Decode.succeed msg | |
| _ -> | |
| Decode.fail "Not enter key" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment