angular-mousetrap

Angular Mousetrap directives, based on Angular UI Keypress


License
MIT
Install
bower install angular-mousetrap

Documentation

Angular Mousetrap directives

Join the chat at https://gitter.im/khasinski/angular-mousetrap GetBadges Game

This is a very crude and probably buggy clone of Angular UI Keypress with Mousetrap under the hood.

Usage

JavaScript:

angular.module('myApp', ['mousetrap']);
...
// Note - it should support any kind of binding that mousetrap supports
$scope.test = {
  'a': function() { console.log('"a" key was pressed'); },
  'b': function() { console.log('"b" key was pressed'); }
}

HTML:

<span mousetrap-keypress="test">Press 'a' or 'b'</span>

Global bindings

Global bindings require Global Binding plugin.

Example usage of global bindings:

$scope.myKeybindings = {
  bindGlobal: {
    'ctrl+s': $scope.saveAction,
    'command+s': $scope.saveAction
  }
  'ctrl+b': $scope.backAction
};

Requirements

  • AngularJS v1.0.2+
  • Mousetrap v1.4.4+