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