keycode-0.2.2: Maps web browser keycodes to their corresponding keyboard keys

Copyright(C) 2015-2016 Ryan Scott
LicenseBSD-style (see the file LICENSE)
MaintainerRyan Scott
StabilityExperimental
PortabilityPortable
Safe HaskellNone
LanguageHaskell98

Web.KeyCode

Description

Keyboard events in web browsers are often represented as keycodes, which (1) are difficult to remember, and (2) sometimes vary from browser to browser. This module allows one to look up a key press's KeyCode and get a plain English description of the Key that was pressed, to reduce confusion.

Since: 0.1

Synopsis

Documentation

data Key Source #

Represents a typical keyboard's keys. The lowercase and uppercase variants of any particular key have the same KeyCode, so there are not separate constructors for them. There is also an UnknownKey constructor for keys without a particular KeyCode.

Note that the Enum instance does not correspond to the KeyCodes, but is simply provided for convenience.

Since: 0.1

Constructors

Backspace 
Tab 
NumLock 
Enter 
Shift 
Control 
Alt 
Pause 
CapsLock 
Escape 
Space 
PageUp 
PageDown 
End 
Home 
ArrowLeft 
ArrowUp 
ArrowRight 
ArrowDown 
PrintScreen 
Insert 
Delete 
Digit0

Without Shift: 0. With Shift: ).

Digit1

Without Shift: 1. With Shift: !.

Digit2

Without Shift: 2. With Shift: @.

Digit3

Without Shift: 3. With Shift: #.

Digit4

Without Shift: 4. With Shift: $.

Digit5

Without Shift: 5. With Shift: %.

Digit6

Without Shift: 6. With Shift: ^.

Digit7

Without Shift: 7. With Shift: &.

Digit8

Without Shift: 8. With Shift: *.

Digit9

Without Shift: 9. With Shift: (.

KeyA

Without Shift: a. With Shift: A.

KeyB

Without Shift: b. With Shift: B.

KeyC

Without Shift: c. With Shift: C.

KeyD

Without Shift: d. With Shift: D.

KeyE

Without Shift: e. With Shift: E.

KeyF

Without Shift: f. With Shift: F.

KeyG

Without Shift: g. With Shift: G.

KeyH

Without Shift: h. With Shift: H.

KeyI

Without Shift: i. With Shift: I.

KeyJ

Without Shift: j. With Shift: J.

KeyK

Without Shift: k. With Shift: K.

KeyL

Without Shift: l. With Shift: L.

KeyM

Without Shift: m. With Shift: M.

KeyN

Without Shift: n. With Shift: N.

KeyO

Without Shift: o. With Shift: O.

KeyP

Without Shift: p. With Shift: P.

KeyQ

Without Shift: q. With Shift: Q.

KeyR

Without Shift: r. With Shift: R.

KeyS

Without Shift: s. With Shift: S.

KeyT

Without Shift: t. With Shift: T.

KeyU

Without Shift: u. With Shift: U.

KeyV

Without Shift: v. With Shift: V.

KeyW

Without Shift: w. With Shift: W.

KeyX

Without Shift: x. With Shift: X.

KeyY

Without Shift: y. With Shift: Y.

KeyZ

Without Shift: z. With Shift: Z.

Command

Might also be the Windows key or the Super key

Numpad0 
Numpad1 
Numpad2 
Numpad3 
Numpad4 
Numpad5 
Numpad6 
Numpad7 
Numpad8 
Numpad9 
NumpadMultiply 
NumpadAdd 
NumpadEnter 
NumpadSubtract 
NumpadDecimal 
NumpadDivide 
F1 
F2 
F3 
F4 
F5 
F6 
F7 
F8 
F9 
F10 
F11 
F12 
ScrollLock 
Semicolon

Without Shift: ;. With Shift: :.

Equals

Without Shift: =. With Shift: +.

Comma

Without Shift: ,. With Shift: <.

Subtract

Without Shift: -. With Shift: _.

Period

Without Shift: .. With Shift: >.

ForwardSlash

Without Shift: /. With Shift: ?.

Backquote

Without Shift: `. With Shift: ~.

BracketLeft

Without Shift: [. With Shift: {.

Backslash

Without Shift: \. With Shift: |.

BracketRight

Without Shift: ]. With Shift: }.

Apostrophe

Without Shift: '. With Shift: ".

UnknownKey 

Instances

Bounded Key Source # 

Methods

minBound :: Key #

maxBound :: Key #

Enum Key Source # 

Methods

succ :: Key -> Key #

pred :: Key -> Key #

toEnum :: Int -> Key #

fromEnum :: Key -> Int #

enumFrom :: Key -> [Key] #

enumFromThen :: Key -> Key -> [Key] #

enumFromTo :: Key -> Key -> [Key] #

enumFromThenTo :: Key -> Key -> Key -> [Key] #

Eq Key Source # 

Methods

(==) :: Key -> Key -> Bool #

(/=) :: Key -> Key -> Bool #

Data Key Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Key -> c Key #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Key #

toConstr :: Key -> Constr #

dataTypeOf :: Key -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Key) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key) #

gmapT :: (forall b. Data b => b -> b) -> Key -> Key #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r #

gmapQ :: (forall d. Data d => d -> u) -> Key -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Key -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Key -> m Key #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key #

Ord Key Source # 

Methods

compare :: Key -> Key -> Ordering #

(<) :: Key -> Key -> Bool #

(<=) :: Key -> Key -> Bool #

(>) :: Key -> Key -> Bool #

(>=) :: Key -> Key -> Bool #

max :: Key -> Key -> Key #

min :: Key -> Key -> Key #

Read Key Source # 
Show Key Source # 

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

Ix Key Source # 

Methods

range :: (Key, Key) -> [Key] #

index :: (Key, Key) -> Key -> Int #

unsafeIndex :: (Key, Key) -> Key -> Int

inRange :: (Key, Key) -> Key -> Bool #

rangeSize :: (Key, Key) -> Int #

unsafeRangeSize :: (Key, Key) -> Int

Generic Key Source # 

Associated Types

type Rep Key :: * -> * #

Methods

from :: Key -> Rep Key x #

to :: Rep Key x -> Key #

Lift Key Source # 

Methods

lift :: Key -> Q Exp #

type Rep Key Source # 
type Rep Key = D1 (MetaData "Key" "Web.KeyCode" "keycode-0.2.2-IeVa075fNUMKYIcFegCNru" False) ((:+:) ((:+:) ((:+:) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "Backspace" PrefixI False) U1) ((:+:) (C1 (MetaCons "Tab" PrefixI False) U1) (C1 (MetaCons "NumLock" PrefixI False) U1))) ((:+:) (C1 (MetaCons "Enter" PrefixI False) U1) ((:+:) (C1 (MetaCons "Shift" PrefixI False) U1) (C1 (MetaCons "Control" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "Alt" PrefixI False) U1) ((:+:) (C1 (MetaCons "Pause" PrefixI False) U1) (C1 (MetaCons "CapsLock" PrefixI False) U1))) ((:+:) (C1 (MetaCons "Escape" PrefixI False) U1) ((:+:) (C1 (MetaCons "Space" PrefixI False) U1) (C1 (MetaCons "PageUp" PrefixI False) U1))))) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "PageDown" PrefixI False) U1) ((:+:) (C1 (MetaCons "End" PrefixI False) U1) (C1 (MetaCons "Home" PrefixI False) U1))) ((:+:) (C1 (MetaCons "ArrowLeft" PrefixI False) U1) ((:+:) (C1 (MetaCons "ArrowUp" PrefixI False) U1) (C1 (MetaCons "ArrowRight" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "ArrowDown" PrefixI False) U1) ((:+:) (C1 (MetaCons "PrintScreen" PrefixI False) U1) (C1 (MetaCons "Insert" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "Delete" PrefixI False) U1) (C1 (MetaCons "Digit0" PrefixI False) U1)) ((:+:) (C1 (MetaCons "Digit1" PrefixI False) U1) (C1 (MetaCons "Digit2" PrefixI False) U1)))))) ((:+:) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "Digit3" PrefixI False) U1) ((:+:) (C1 (MetaCons "Digit4" PrefixI False) U1) (C1 (MetaCons "Digit5" PrefixI False) U1))) ((:+:) (C1 (MetaCons "Digit6" PrefixI False) U1) ((:+:) (C1 (MetaCons "Digit7" PrefixI False) U1) (C1 (MetaCons "Digit8" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "Digit9" PrefixI False) U1) ((:+:) (C1 (MetaCons "KeyA" PrefixI False) U1) (C1 (MetaCons "KeyB" PrefixI False) U1))) ((:+:) (C1 (MetaCons "KeyC" PrefixI False) U1) ((:+:) (C1 (MetaCons "KeyD" PrefixI False) U1) (C1 (MetaCons "KeyE" PrefixI False) U1))))) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "KeyF" PrefixI False) U1) ((:+:) (C1 (MetaCons "KeyG" PrefixI False) U1) (C1 (MetaCons "KeyH" PrefixI False) U1))) ((:+:) (C1 (MetaCons "KeyI" PrefixI False) U1) ((:+:) (C1 (MetaCons "KeyJ" PrefixI False) U1) (C1 (MetaCons "KeyK" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "KeyL" PrefixI False) U1) ((:+:) (C1 (MetaCons "KeyM" PrefixI False) U1) (C1 (MetaCons "KeyN" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "KeyO" PrefixI False) U1) (C1 (MetaCons "KeyP" PrefixI False) U1)) ((:+:) (C1 (MetaCons "KeyQ" PrefixI False) U1) (C1 (MetaCons "KeyR" PrefixI False) U1))))))) ((:+:) ((:+:) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "KeyS" PrefixI False) U1) ((:+:) (C1 (MetaCons "KeyT" PrefixI False) U1) (C1 (MetaCons "KeyU" PrefixI False) U1))) ((:+:) (C1 (MetaCons "KeyV" PrefixI False) U1) ((:+:) (C1 (MetaCons "KeyW" PrefixI False) U1) (C1 (MetaCons "KeyX" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "KeyY" PrefixI False) U1) ((:+:) (C1 (MetaCons "KeyZ" PrefixI False) U1) (C1 (MetaCons "Command" PrefixI False) U1))) ((:+:) (C1 (MetaCons "Numpad0" PrefixI False) U1) ((:+:) (C1 (MetaCons "Numpad1" PrefixI False) U1) (C1 (MetaCons "Numpad2" PrefixI False) U1))))) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "Numpad3" PrefixI False) U1) ((:+:) (C1 (MetaCons "Numpad4" PrefixI False) U1) (C1 (MetaCons "Numpad5" PrefixI False) U1))) ((:+:) (C1 (MetaCons "Numpad6" PrefixI False) U1) ((:+:) (C1 (MetaCons "Numpad7" PrefixI False) U1) (C1 (MetaCons "Numpad8" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "Numpad9" PrefixI False) U1) ((:+:) (C1 (MetaCons "NumpadMultiply" PrefixI False) U1) (C1 (MetaCons "NumpadAdd" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "NumpadEnter" PrefixI False) U1) (C1 (MetaCons "NumpadSubtract" PrefixI False) U1)) ((:+:) (C1 (MetaCons "NumpadDecimal" PrefixI False) U1) (C1 (MetaCons "NumpadDivide" PrefixI False) U1)))))) ((:+:) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "F1" PrefixI False) U1) ((:+:) (C1 (MetaCons "F2" PrefixI False) U1) (C1 (MetaCons "F3" PrefixI False) U1))) ((:+:) (C1 (MetaCons "F4" PrefixI False) U1) ((:+:) (C1 (MetaCons "F5" PrefixI False) U1) (C1 (MetaCons "F6" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "F7" PrefixI False) U1) ((:+:) (C1 (MetaCons "F8" PrefixI False) U1) (C1 (MetaCons "F9" PrefixI False) U1))) ((:+:) (C1 (MetaCons "F10" PrefixI False) U1) ((:+:) (C1 (MetaCons "F11" PrefixI False) U1) (C1 (MetaCons "F12" PrefixI False) U1))))) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "ScrollLock" PrefixI False) U1) ((:+:) (C1 (MetaCons "Semicolon" PrefixI False) U1) (C1 (MetaCons "Equals" PrefixI False) U1))) ((:+:) (C1 (MetaCons "Comma" PrefixI False) U1) ((:+:) (C1 (MetaCons "Subtract" PrefixI False) U1) (C1 (MetaCons "Period" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "ForwardSlash" PrefixI False) U1) ((:+:) (C1 (MetaCons "Backquote" PrefixI False) U1) (C1 (MetaCons "BracketLeft" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "Backslash" PrefixI False) U1) (C1 (MetaCons "BracketRight" PrefixI False) U1)) ((:+:) (C1 (MetaCons "Apostrophe" PrefixI False) U1) (C1 (MetaCons "UnknownKey" PrefixI False) U1))))))))

type KeyCode = Int Source #

A numeric code representing the value of a pressed Key. Note that a particular Key may not uniquely map to a particular KeyCode, as the implementation of key codes is browser-dependent.

Since: 0.1

keyCodeLookup :: KeyCode -> Key Source #

Determine the Key that a KeyCode represents. If one cannot be found, UnknownKey is returned.

Since: 0.1

keyCodeMap :: IntMap Key Source #

An map of known KeyCodes to Keys.

Since: 0.1

isKeyCode :: Key -> KeyCode -> Bool Source #

Return True if the given KeyCode matches the given Key.

Since: 0.2.2