aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Edition/TimeEdition.elm
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-03-22 13:29:45 +0100
committerJoris Guyonvarch2015-03-22 13:29:45 +0100
commit7e442c937e1d0696c2cff591a06e869f92d08595 (patch)
tree8edc523d64b06cdd31c3d19bb93fa87b18de613f /src/Model/Edition/TimeEdition.elm
parent2abb8ffa46cbe86deedb9ddcbb9b042b51285feb (diff)
Better support from keyboard thanks to event.which on key press
Diffstat (limited to 'src/Model/Edition/TimeEdition.elm')
-rw-r--r--src/Model/Edition/TimeEdition.elm16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/Model/Edition/TimeEdition.elm b/src/Model/Edition/TimeEdition.elm
index 6999b25..2ba1628 100644
--- a/src/Model/Edition/TimeEdition.elm
+++ b/src/Model/Edition/TimeEdition.elm
@@ -9,24 +9,16 @@ import List
import Array
import String
import Keyboard (KeyCode)
+import Char
import Utils.List (..)
import Utils.Maybe (..)
keyCodeToChar : KeyCode -> Maybe Char
keyCodeToChar code =
- List.map (flip keyCodeToCharFromZero code) zeroKeyCodes
- |> List.foldl orElse Nothing
-
-zeroKeyCodes = [48, 96]
-
-keyCodeToCharFromZero : KeyCode -> KeyCode -> Maybe Char
-keyCodeToCharFromZero zero code =
- let nine = zero + 9
- in if code >= zero && code <= nine
- then ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
- |> Array.fromList
- |> Array.get (code - zero)
+ let char = Char.fromCode code
+ in if Char.isDigit char
+ then Just char
else Nothing
toTime : List Char -> Time