Created
March 3, 2018 18:42
-
-
Save ronanyeah/b3a5bf2a62e48b7d745867567e0c4353 to your computer and use it in GitHub Desktop.
Escape Listener
This file contains 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
onEsc : msg -> Decoder msg | |
onEsc msg = | |
Decode.map2 | |
(\keyCode key -> | |
keyCode == 27 || key == "Escape" | |
) | |
keyCode | |
(Decode.field "key" Decode.string) | |
|> Decode.andThen | |
(\match -> | |
if match then | |
Decode.succeed msg | |
else | |
Decode.fail "" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment