AngularJS ng-keydown Instruction
AngularJS Examples
Code to execute when a key is pressed:
<
input
ng-keydown="count = count + 1"
ng-init=
"count=0"
/
<
h1
{{count}}
<
/h1Try it »
Definition and Usage
ng-keydown The directive tells AngularJS the action to take when a key is pressed on the specified HTML element.
ng-keydown The directive does not override the element's native onkeydown event. When the event is triggered,ng-keydown both the expression and the native onkeydown event will be executed.
The event order of key strokes:
- Keydown
- Keypress
- Keyup
Syntax
<
element
ng-keydown=
"expression"
<
/element,
Parameter value
| Value | Description |
|---|---|
| expression | The expression to execute when a key is pressed. |
AngularJS Reference Manual