参考这个页面。http://www.angularjshub.com/examples/eventhandlers/keyboardevents/
Html页面代码:
<input ng-model='keyword' ng-keyup="checkKeyCode($event)" type="text" placeholder="输入关键字"/> Angular JS代码:
$scope.checkKeyCode = function(e){
console.log(e.keyCode);
}; 这个事件的关键是前端需要传递$event给JS中相应的函数,否则JS无法获取相应的keyCode.