AngularJs 键盘事件和鼠标事件

Posted 品读夜的黑

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AngularJs 键盘事件和鼠标事件相关的知识,希望对你有一定的参考价值。

ngKeydown/ngKeypress/ngKeyup

该指令在按键按下/按键按下/按键松开时执行指定表达式。

ngKeydown和ngKeypress略有不同,目前的测试是ngKeypress针对系统按键是无效的,而ngKeydown可以。

ngKeyup指令在按键松开的时候执行。

使用代码:

  <input ng-keydown="count = count + 1" ng-init="count=0">{{count}}
  <input ng-keypress="count = count + 1" ng-init="count=0">{{count}}
  <input ng-keyup="count = count + 1" ng-init="count=0">{{count}}

ngMousedown/ngMouseenter/ngMouseleave/ngMousemove/ngMouseover/ngMouseup

该指令在鼠标按下/鼠标进入/鼠标离开/鼠标移动/鼠标在上面/鼠标松开时执行指定表达式。

使用代码:

  <button ng-mousedown="count = count + 1" ng-init="count=0">on mouse down</button>{{count}}
  <button ng-mouseenter="count = count + 1" ng-init="count=0">when mouse enter</button>{{count}}
  <button ng-mouseleave="count = count + 1" ng-init="count=0">when mouse leave</button>{{count}}
  <button ng-mousemove="count = count + 1" ng-init="count=0">when mouse move</button>{{count}}
  <button ng-mouseover="count = count + 1" ng-init="count=0">when mouse is over</button>{{count}}
  <button ng-mouseup="count = count + 1" ng-init="count=0">on mouse up</button>{{count}}

以上是关于AngularJs 键盘事件和鼠标事件的主要内容,如果未能解决你的问题,请参考以下文章

selenium的鼠标和键盘事件

golang调用sdl2,键盘和鼠标事件

WPF之路-键盘与鼠标事件 - 简书

在AngularJS中的滚动事件上获取鼠标位置

在AngularJS中的滚动事件上获取鼠标位置

angularjs中的事件传播$emit,$broadcast,$on