browser-keymap-lite

Keyboard shortcuts for browser

npm install browser-keymap-lite
6 downloads in the last week
12 downloads in the last month
@version  0.1.4
@date     2013-07-13

Browser Keymap

Keyboard shortcuts. Download compressed (889 bytes, 599 bytes gzipped) or uncompressed source.

Usage

var keyMap = {
    H: function(event, key) {
        // metacode
        View("help").open()

        // attach subview keymap
        Event.setKeyMap(subViewKeyMap)
    },
    num: function(event, num) {
        alert("number "+num+" pressed")
    }
}
var subViewKeyMap = {
    // override H key - help is already open
    H: function(){},
    esc: function() {
        // metacode
        View("help").close()

        // remove subview keymap
        Event.rmKeyMap(subViewKeyMap)
    },
    // Keypresses are bubbled up to previous view
    bubble: true
}

// attach default keymap
Event.setKeyMap(keyMap)

Licence

Copyright (c) 2012 Lauri Rooden <lauri@rooden.ee>
The MIT License

npm loves you