Skip to content

amilner42/keyboard-extra

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keyboard Extra

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

NOTE: I haven't upgraded this to Elm 0.19, I don't intend on doing this either, I'm not sure I want to keep this library alive.

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
       -- ...
       ]

About

[DEPRECATED] Higher level handling for elm-lang/keyboard

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elm 100.0%