AngularJS ng-keydown-instructie

Definitie en gebruik

ng-keydown Het commando vertelt AngularJS wat te doen wanneer de toetsenbord wordt gebruikt op een specifiek HTML-element.

AngularJS' ng-keydown Directives do not override the original onkeydown event of the element, both will be executed.

The order of keystrokes is:

  1. Keydown (Keyboard Pressed)
  2. Keypress (Keyboard Press)
  3. Keyup (Keyboard Release)

Example

Execute an expression each time a key is pressed:

<input ng-keydown="count = count + 1" ng-init="count=0" />
<h1>{{count}}</h1>

Try it yourself

Syntax

<element ng-keydown="expression</element>

Support <input>,<select>,<textarea> and other editable elements.

Parameters

Parameters Description
expression The expression to be executed when the key is pressed.