sdl2-2.5.5.0: Both high- and low-level bindings to the SDL library (version 2.0.6+).

Safe Haskell | Safe-Inferred
Language | Haskell2010

SDL.Input.Keyboard

Contents

- Keyboard Modifiers
- Text Input
- Screen Keyboard
- Scancodes
- Keycodes
- Keysym
- Keycodes and Scancodes

Synopsis

- getModState :: (Functor m, MonadIO m) => m KeyModifier
- data KeyModifier = KeyModifier {
  - keyModifierLeftShift :: Bool
  - keyModifierRightShift :: Bool
  - keyModifierLeftCtrl :: Bool
  - keyModifierRightCtrl :: Bool
  - keyModifierLeftAlt :: Bool
  - keyModifierRightAlt :: Bool
  - keyModifierLeftGUI :: Bool
  - keyModifierRightGUI :: Bool
  - keyModifierNumLock :: Bool
  - keyModifierCapsLock :: Bool
  - keyModifierAltGr :: Bool
  }
- getKeyboardState :: MonadIO m => m (Scancode -> Bool)
- startTextInput :: MonadIO m => Rect -> m ()
- stopTextInput :: MonadIO m => m ()
- hasScreenKeyboardSupport :: MonadIO m => m Bool
- isScreenKeyboardShown :: MonadIO m => Window -> m Bool
- getScancodeName :: MonadIO m => Scancode -> m String
- newtype Scancode = Scancode {
  - unwrapScancode :: Word32
  }
- newtype Keycode = Keycode {
  - unwrapKeycode :: Int32
  }
- data Keysym = Keysym {
  - keysymScancode :: Scancode
  - keysymKeycode :: Keycode
  - keysymModifier :: KeyModifier
  }
- module SDL.Input.Keyboard.Codes

# Keyboard Modifiers

getModState :: (Functor m, MonadIO m) => m KeyModifier Source #

Get the current key modifier state for the keyboard. The key modifier state is a mask special keys that are held down.

See `SDL_GetModState` for C documentation.

data KeyModifier Source #

Information about which keys are currently held down. Use `getModState` to generate this information.

Constructors

KeyModifier |

Fields

- keyModifierLeftShift :: Bool
- keyModifierRightShift :: Bool
- keyModifierLeftCtrl :: Bool
- keyModifierRightCtrl :: Bool
- keyModifierLeftAlt :: Bool
- keyModifierRightAlt :: Bool
- keyModifierLeftGUI :: Bool
- keyModifierRightGUI :: Bool
- keyModifierNumLock :: Bool
- keyModifierCapsLock :: Bool
- keyModifierAltGr :: Bool

#### Instances

Instances details

Data KeyModifier Source # |

Instance details

Defined in SDL.Input.Keyboard

Methods

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

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

toConstr :: KeyModifier -> Constr Source #

dataTypeOf :: KeyModifier -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Generic KeyModifier Source # |
Instance details Defined in SDL.Input.Keyboard Associated Types type Rep KeyModifier :: Type -> Type Source # Methods from :: KeyModifier -> Rep KeyModifier x Source # to :: Rep KeyModifier x -> KeyModifier Source #
Read KeyModifier Source # |
Instance details Defined in SDL.Input.Keyboard Methods readsPrec :: Int -> ReadS KeyModifier Source # readList :: ReadS [KeyModifier] Source # readPrec :: ReadPrec KeyModifier Source # readListPrec :: ReadPrec [KeyModifier] Source #
Show KeyModifier Source # |
Instance details Defined in SDL.Input.Keyboard Methods showsPrec :: Int -> KeyModifier -> ShowS Source # show :: KeyModifier -> String Source # showList :: [KeyModifier] -> ShowS Source #
Eq KeyModifier Source # |
Instance details Defined in SDL.Input.Keyboard Methods (==) :: KeyModifier -> KeyModifier -> Bool Source # (/=) :: KeyModifier -> KeyModifier -> Bool Source #
Ord KeyModifier Source # |

Instance details

Defined in SDL.Input.Keyboard

Methods

compare :: KeyModifier -> KeyModifier -> Ordering Source #

(<) :: KeyModifier -> KeyModifier -> Bool Source #

(<=) :: KeyModifier -> KeyModifier -> Bool Source #

(>) :: KeyModifier -> KeyModifier -> Bool Source #

(>=) :: KeyModifier -> KeyModifier -> Bool Source #

max :: KeyModifier -> KeyModifier -> KeyModifier Source #

min :: KeyModifier -> KeyModifier -> KeyModifier Source #

FromNumber KeyModifier Word32 Source # |
Instance details Defined in SDL.Input.Keyboard Methods fromNumber :: Word32 -> KeyModifier Source #
ToNumber KeyModifier Word32 Source # |
Instance details Defined in SDL.Input.Keyboard Methods toNumber :: KeyModifier -> Word32 Source #
type Rep KeyModifier Source # |

Instance details

Defined in SDL.Input.Keyboard

type Rep KeyModifier = D1 ('MetaData "KeyModifier" "SDL.Input.Keyboard" "sdl2-2.5.5.0-1rHVQtCfQoNJ4T4oR9opIh" 'False) (C1 ('MetaCons "KeyModifier" 'PrefixI 'True) (((S1 ('MetaSel ('Just "keyModifierLeftShift") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "keyModifierRightShift") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "keyModifierLeftCtrl") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "keyModifierRightCtrl") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "keyModifierLeftAlt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))) :*: ((S1 ('MetaSel ('Just "keyModifierRightAlt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "keyModifierLeftGUI") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "keyModifierRightGUI") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))) :*: (S1 ('MetaSel ('Just "keyModifierNumLock") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "keyModifierCapsLock") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "keyModifierAltGr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))))

getKeyboardState :: MonadIO m => m (Scancode -> Bool) Source #

Get a snapshot of the current state of the keyboard.

This computation generates a mapping from `Scancode` to `Bool` - evaluating the function at specific `Scancode`s will inform you as to whether or not that key was held down when `getKeyboardState` was called.

See `SDL_GetKeyboardState` for C documentation.

# Text Input

startTextInput :: MonadIO m => Rect -> m () Source #

Set the rectangle used to type text inputs and start accepting text input events.

See `SDL_StartTextInput` for C documentation.

stopTextInput :: MonadIO m => m () Source #

Stop receiving any text input events.

See `SDL_StopTextInput` for C documentation.

# Screen Keyboard

hasScreenKeyboardSupport :: MonadIO m => m Bool Source #

Check whether the platform has screen keyboard support.

See `SDL_HasScreenKeyboardSupport` for C documentation.

isScreenKeyboardShown :: MonadIO m => Window -> m Bool Source #

Check whether the screen keyboard is shown for the given window.

See `SDL_IsScreenKeyboardShown` for C documentation.

# Scancodes

getScancodeName :: MonadIO m => Scancode -> m String Source #

Get a human-readable name for a scancode. If the scancode doesn't have a name this function returns the empty string.

See `SDL_GetScancodeName` for C documentation.

newtype Scancode Source #

Constructors

Scancode |

Fields

- unwrapScancode :: Word32

#### Instances

Instances details

Data Scancode Source # |

Instance details

Defined in SDL.Input.Keyboard.Codes

Methods

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

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

toConstr :: Scancode -> Constr Source #

dataTypeOf :: Scancode -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Bounded Scancode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods minBound :: Scancode Source # maxBound :: Scancode Source #
Generic Scancode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Associated Types type Rep Scancode :: Type -> Type Source # Methods from :: Scancode -> Rep Scancode x Source # to :: Rep Scancode x -> Scancode Source #
Read Scancode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods readsPrec :: Int -> ReadS Scancode Source # readList :: ReadS [Scancode] Source # readPrec :: ReadPrec Scancode Source # readListPrec :: ReadPrec [Scancode] Source #
Show Scancode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods showsPrec :: Int -> Scancode -> ShowS Source # show :: Scancode -> String Source # showList :: [Scancode] -> ShowS Source #
Eq Scancode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods (==) :: Scancode -> Scancode -> Bool Source # (/=) :: Scancode -> Scancode -> Bool Source #
Ord Scancode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods compare :: Scancode -> Scancode -> Ordering Source # (<) :: Scancode -> Scancode -> Bool Source # (<=) :: Scancode -> Scancode -> Bool Source # (>) :: Scancode -> Scancode -> Bool Source # (>=) :: Scancode -> Scancode -> Bool Source # max :: Scancode -> Scancode -> Scancode Source # min :: Scancode -> Scancode -> Scancode Source #
FromNumber Scancode Word32 Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods fromNumber :: Word32 -> Scancode Source #
ToNumber Scancode Word32 Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods toNumber :: Scancode -> Word32 Source #
type Rep Scancode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes type Rep Scancode = D1 ('MetaData "Scancode" "SDL.Input.Keyboard.Codes" "sdl2-2.5.5.0-1rHVQtCfQoNJ4T4oR9opIh" 'True) (C1 ('MetaCons "Scancode" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapScancode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32)))

# Keycodes

newtype Keycode Source #

Constructors

Keycode |

Fields

- unwrapKeycode :: Int32

#### Instances

Instances details

Data Keycode Source # |

Instance details

Defined in SDL.Input.Keyboard.Codes

Methods

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

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

toConstr :: Keycode -> Constr Source #

dataTypeOf :: Keycode -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Bounded Keycode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods minBound :: Keycode Source # maxBound :: Keycode Source #
Generic Keycode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Associated Types type Rep Keycode :: Type -> Type Source # Methods from :: Keycode -> Rep Keycode x Source # to :: Rep Keycode x -> Keycode Source #
Read Keycode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods readsPrec :: Int -> ReadS Keycode Source # readList :: ReadS [Keycode] Source # readPrec :: ReadPrec Keycode Source # readListPrec :: ReadPrec [Keycode] Source #
Show Keycode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods showsPrec :: Int -> Keycode -> ShowS Source # show :: Keycode -> String Source # showList :: [Keycode] -> ShowS Source #
Eq Keycode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods (==) :: Keycode -> Keycode -> Bool Source # (/=) :: Keycode -> Keycode -> Bool Source #
Ord Keycode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods compare :: Keycode -> Keycode -> Ordering Source # (<) :: Keycode -> Keycode -> Bool Source # (<=) :: Keycode -> Keycode -> Bool Source # (>) :: Keycode -> Keycode -> Bool Source # (>=) :: Keycode -> Keycode -> Bool Source # max :: Keycode -> Keycode -> Keycode Source # min :: Keycode -> Keycode -> Keycode Source #
FromNumber Keycode Int32 Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods fromNumber :: Int32 -> Keycode Source #
ToNumber Keycode Int32 Source # |
Instance details Defined in SDL.Input.Keyboard.Codes Methods toNumber :: Keycode -> Int32 Source #
type Rep Keycode Source # |
Instance details Defined in SDL.Input.Keyboard.Codes type Rep Keycode = D1 ('MetaData "Keycode" "SDL.Input.Keyboard.Codes" "sdl2-2.5.5.0-1rHVQtCfQoNJ4T4oR9opIh" 'True) (C1 ('MetaCons "Keycode" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapKeycode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int32)))

# Keysym

data Keysym Source #

Information about a key press or key release event.

Constructors

Keysym |

Fields

- keysymScancode :: Scancode

  The keyboard `Scancode`

- keysymKeycode :: Keycode

  SDL's virtual key representation for this key

- keysymModifier :: KeyModifier

  A set of modifiers that were held at the time this data was generated

#### Instances

Instances details

Data Keysym Source # |

Instance details

Defined in SDL.Input.Keyboard

Methods

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

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

toConstr :: Keysym -> Constr Source #

dataTypeOf :: Keysym -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Generic Keysym Source # |
Instance details Defined in SDL.Input.Keyboard Associated Types type Rep Keysym :: Type -> Type Source # Methods from :: Keysym -> Rep Keysym x Source # to :: Rep Keysym x -> Keysym Source #
Read Keysym Source # |
Instance details Defined in SDL.Input.Keyboard Methods readsPrec :: Int -> ReadS Keysym Source # readList :: ReadS [Keysym] Source # readPrec :: ReadPrec Keysym Source # readListPrec :: ReadPrec [Keysym] Source #
Show Keysym Source # |
Instance details Defined in SDL.Input.Keyboard Methods showsPrec :: Int -> Keysym -> ShowS Source # show :: Keysym -> String Source # showList :: [Keysym] -> ShowS Source #
Eq Keysym Source # |
Instance details Defined in SDL.Input.Keyboard Methods (==) :: Keysym -> Keysym -> Bool Source # (/=) :: Keysym -> Keysym -> Bool Source #
Ord Keysym Source # |
Instance details Defined in SDL.Input.Keyboard Methods compare :: Keysym -> Keysym -> Ordering Source # (<) :: Keysym -> Keysym -> Bool Source # (<=) :: Keysym -> Keysym -> Bool Source # (>) :: Keysym -> Keysym -> Bool Source # (>=) :: Keysym -> Keysym -> Bool Source # max :: Keysym -> Keysym -> Keysym Source # min :: Keysym -> Keysym -> Keysym Source #
type Rep Keysym Source # |

Instance details

Defined in SDL.Input.Keyboard

type Rep Keysym = D1 ('MetaData "Keysym" "SDL.Input.Keyboard" "sdl2-2.5.5.0-1rHVQtCfQoNJ4T4oR9opIh" 'False) (C1 ('MetaCons "Keysym" 'PrefixI 'True) (S1 ('MetaSel ('Just "keysymScancode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Scancode) :*: (S1 ('MetaSel ('Just "keysymKeycode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Keycode) :*: S1 ('MetaSel ('Just "keysymModifier") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 KeyModifier))))

# Keycodes and Scancodes

module SDL.Input.Keyboard.Codes