angular js 的 ng-keyup 监听 keydown keyup事件获取 keyCode
参考这个页面。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.
浙公网安备 33010602011771号