Reputation: 3161
I don't know how I can intercept a keydown event of the window and set from there an angular var into the scope, of a specify controller.
Upvotes: 1
Views: 1312
Reputation: 8427
Here is a simple way to do it from your controller.
angular.element(window).bind("keydown",keydown);
function keydown(e) {
$scope.eventKeydown = e.keyCode;
$scope.$apply();
}
Upvotes: 1
Reputation: 2023
You can use this:
window.onkeydown = keydown;
function keydown(e) {
$scope.eventKeydown = e;
console.log(e);
console.log($scope.eventKeydown);
}
Upvotes: 0