This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Work with keyboard events and keep track of recent keys.
version 3.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 3.0.0
Committed At 2018-04-27 01:41:02 UTC
elm-lang/keyboard 1.0.1 <= v < 2.0.0 1.0.1
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1

README

Keyboard Extra

Forked from: https://github.com/ohanhi/keyboard-extra.

Description

A very lightweight library to create hotkeys for apps. Not intended for games.

Warning

Javascript has issues with key events

Usage

Add it to your Model:

type alias Model =
    { keysDown : Keyboard.Extra.Model
    -- ...
    }

Add it to your init:

init =
    { keysDown = Keyboard.Extra.init
    -- ...
    }

-- If your init also expects a Cmd then pair it with Cmd.none.

Add it to your messages:

type Msg =
    KeyboardExtraMsg Keyboard.Extra.Msg
    -- ...

Add it to your update.

case msg of
    KeyboardExtraMsg keyMsg ->
        let
            newKeysDown =
                Keyboard.Extra.update keyMsg model.keysDown
        in
            -- If you want to react to key-presses, call a function here instead
            -- of just updating the model (you should still update the model).
            ({ model | keysDown = newKeysDown }, Cmd.none)
    -- ...

And lastly, hook up your subscriptions:

subscriptions model =
    Sub.batch
       [ Sub.map KeyboardExtraMsg Keyboard.Extra.subscriptions
       -- ...
       ]