How to listen for key presses with AngularJS

I needed to create a table that can be browsed around with the arrow keys in an AngularJS app. The documentation about ng-keypress on the AngularJS site is pretty minimal. E.g. it does not mention that you can call a function that passes an $event object containing the keypress. I created a small jsfiddle demo to show you how to catch virtually all key presses on your Angular site, like arrow keys, return, function keys, all letters and numbers, etc.

One word of warning: this works for angularjs 1.1.5 and up. Check out the JSFiddle: Catching key presses with AngularJS


Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Trackbacks and Pingbacks: