Looks like you can use the ng-keydown to do this.
Here is a working plunker.
For this sample, I just bound ng-keydown
to
. Works pretty well to catch all the keyboard events globally.
As @charlietfl points out, ng-keydown
registers a lot of keyboard events so to make this usable would be a lot of work. For example, if you were trying to listen for a combination (like ctrl
+ r
), then the ctrl
key will register many times.
JS:
var myApp = angular.module('myApp', []);
myApp.controller('Ctrl', function($scope) {
$scope.keyBuffer = [];
function arrays_equal(a,b) { return !(a
HTML: