Angular does not update UI for keyboard event

Friday, July 4, 2014

I want to update page for keyboard event. I wired the keyboard event through $window.document.onkeydown. (I know this is not good but it is supposed to work)

However, I find that the page is not updating even the model is changed! Where am I missing ?

<!doctype html>
<meta charset="utf-8">
function Main ($scope, $window) {
$scope.keyCode = 0;
$window.document.onkeydown = function (event) {
$scope.keyCode = event.keyCode;
console.log($scope.keyCode); //the model is changed here
<body ng-app>
<div ng-controller="Main">
<script type="text/javascript" src="bower_components/angular/angular.js"></script>