Skip to content

visheshjoshi/ember-mousetrap

 
 

Repository files navigation

ember-mousetrap

Mousetrap integration for Ember.js.

Installation

$ ember install:npm 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]);
    })
  }
});

About

Mousetrap integration for Ember.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 75.1%
  • HTML 23.6%
  • Other 1.3%