I've set up a Plunker with some example code: http://plnkr.co/edit/upExTHzpkwtZ45mdikFr?p=preview
The very succinct question is: I'm trying to use AngularJS' ng-keyUp
directive. In the docs I've only seen is used on an input, although I'm trying to capture keypresses anywhere on the page rather than just inside an input box. Like so:
// view
<div ng-keyup="keyPress($event)">
// The bulk of my controller's view goes in here
</div>
// inside controller
$scope.keyPress = function(e){
console.log(e);
}
Again, see the Plunker above for an example. Currently, it doesn't work at all and nothing is logged. How can I get it to work properly?
Try to give the div element focus, or use tabindex="1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With