Header menu logo Mibo

Keyboard Module

Keyboard input subscriptions for Elmish.

These functions create subscriptions that dispatch messages when keyboard state changes. Requires Program.withInput to be applied.

Example

 let subscribe ctx model =
     Sub.batch [
         Keyboard.onPressed KeyPressed ctx
         Keyboard.onReleased KeyReleased ctx
     ]
val subscribe: ctx: 'a -> model: 'b -> 'c
val ctx: 'a
val model: 'b

Functions and values

Function or value Description

listen onPressed onReleased ctx

Full Usage: listen onPressed onReleased ctx

Parameters:
Returns: Sub<'Msg>

Subscribes to both key press and release events.

The subscription ID is shared, so only one listen subscription can be active at a time per Elmish program.

onPressed : Keys -> 'Msg
onReleased : Keys -> 'Msg
ctx : GameContext
Returns: Sub<'Msg>

onPressed handler ctx

Full Usage: onPressed handler ctx

Parameters:
Returns: Sub<'Msg>

Subscribes to key press events only.

Dispatches the handler for each key that was pressed this frame.

handler : Keys -> 'Msg
ctx : GameContext
Returns: Sub<'Msg>

onReleased handler ctx

Full Usage: onReleased handler ctx

Parameters:
Returns: Sub<'Msg>

Subscribes to key release events only.

handler : Keys -> 'Msg
ctx : GameContext
Returns: Sub<'Msg>

Type something to start searching.