ember-mousetrap

0.3.2 • Public • Published

ember-mousetrap

Mousetrap integration for Ember.js.

Installation

$ ember install ember-mousetrap

Usage

import { MousetrapRoute, mousetrap } from 'ember-mousetrap';
 
export default Ember.Route.extend(MousetrapRoute, {
  shortcuts: {
    // single keys
    foo: mousetrap('4', function() { highlight(2); }),
    bar: mousetrap('x', 'keyup', function() { highlight(3); }),
 
    // combinations
    baz: mousetrap('command+shift+k', function(e) {
      highlight([6, 7, 8, 9]);
      return false;
    }),
 
    qux: mousetrap(['command+k', 'ctrl+k'], function(e) {
      highlight([11, 12, 13, 14]);
      return false;
    }),
 
    // gmail style sequences
    foobar: mousetrap('g i', function() { highlight(17); }),
    foobaz: mousetrap('* a', function() { highlight(18); }),
 
    // konami code!
    mighty: mousetrap('up up down down left right left right b a enter', function() {
      highlight([21, 22, 23]);
    })
  }
});

Readme

Keywords

Package Sidebar

Install

npm i ember-mousetrap

Weekly Downloads

21

Version

0.3.2

License

MIT

Last publish

Collaborators

  • ursm