What is AngularJS way to create global keyboard shortcuts?
I would say a more proper way (or “Angular way”) would be to add it to a directive. Here’s a simple one to get you going (just add keypress-events attribute to <body>): angular.module(‘myDirectives’, []).directive(‘keypressEvents’, [ ‘$document’, ‘$rootScope’, function($document, $rootScope) { return { restrict: ‘A’, link: function() { $document.bind(‘keypress’, function(e) { console.log(‘Got keypress:’, e.which); $rootScope.$broadcast(‘keypress’, e); … Read more