I need to detect keys pressed on a div. In this plunk I have a div, but if I first click on it and then press a key (for example Del) then no event happens. How to make this work?
HTML
Click on the div and press a key:
<div ng-keypress="pressedKey($event)">
</div>
Key pressed: {{myKey}}
Javascript
angular.module("app", [])
.controller('ctl', function($scope) {
$scope.pressedKey = function(event) {
$scope.myKey = event.key;
}
});