SwiftsNamesake / proper-keyboard / Keyboard.Key

Readable and typesafe key names.

Definition


type Key
    = A
    | B
    | C
    | D
    | E
    | F
    | G
    | H
    | I
    | J
    | K
    | L
    | M
    | N
    | O
    | P
    | Q
    | R
    | S
    | T
    | U
    | V
    | W
    | X
    | Y
    | Z
    | Left
    | Right
    | Up
    | Down
    | Shift (Maybe Side)
    | Ctrl (Maybe Side)
    | Alt
    | Tab
    | CapsLock
    | Spacebar
    | Escape
    | Enter
    | Backspace
    | Delete
    | PageUp
    | PageDown
    | End
    | Home
    | Zero
    | One
    | Two
    | Three
    | Four
    | Five
    | Six
    | Seven
    | Eight
    | Nine
    | Insert
    | PrintScreen
    | PauseBreak
    | Windows
    | Command
    | ChromeSearch
    | NumLock
    | ScrollLock
    | F1
    | F2
    | F3
    | F4
    | F5
    | F6
    | F7
    | F8
    | F9
    | F10
    | F11
    | F12
    | NumpadZero
    | NumpadOne
    | NumpadTwo
    | NumpadThree
    | NumpadFour
    | NumpadFive
    | NumpadSix
    | NumpadSeven
    | NumpadEight
    | NumpadNine
    | Multiply
    | Add
    | Subtract
    | Decimal
    | Divide
    | Ambiguous (List Key)
    | Unknown Basics.Int

Represents a Key. Currently incomplete.


type Side
    = LeftHand
    | RightHand

Type used to distinguish between multiple instances of the same key (such as Left Ctrl and Right Ctrl)

fromCode : Basics.Int -> Key

Transform a Int to a Key

code : Key -> Maybe Basics.Int

Attempts to transform a key into a keycode

toChar : Key -> Maybe Char

Attempt to transform a Key into a Char. This does not work for 'special' keys that are not used to type symbols.