{-|
Module : EventLoop.Input.Keyboard
Description : Library of all the possible 'Keyboard' events in the example implementation.
Copyright : (c) Sebastiaan la Fleur, 2014
License : BSD3
Maintainer : sebastiaan.la.fleur@gmail.com
Stability : experimental
Portability : All
This module expresses how the 'Keyboard' IO device is modelled in the example implementation.
-}
module EventLoop.Input.Keyboard(
Keyboard(..),
KeyboardButton
) where
import EventLoop.Json
import EventLoop.Config
-- | Datatype to express the different 'Keyboard' events.
data Keyboard = KeyPress KeyboardButton
-- | Type to express how a 'KeyboardButton' is modelled.
type KeyboardButton = [Char]
-- | Instance to express how a JSON formatted 'String' can be parsed into a 'Keyboard' event.
instance FromJSON Keyboard where
fromJsonMessage (JSONObject ms) = KeyPress button
where
JSONString button = retrieveError buttonS ms