Easy Tutorial
❮ Ng Ng If Ng Ng Include ❯

AngularJS ng-keypress Directive

AngularJS Reference Manual


AngularJS Example

Code to be executed when a key is pressed:


Definition and Usage

The ng-keypress directive is used to tell AngularJS what to do when a key is pressed on the specified HTML element.

The ng-keypress directive does not override the element's native onkeypress event. When the event is triggered, both the ng-keypress expression and the native onkeypress event will be executed.

The sequence of key events is:


Syntax

The directive is supported by <input>, <select>, <textarea>, and other editable elements.


Parameter Values

Value Description
expression The expression to be executed when a key is pressed.

AngularJS Reference Manual

❮ Ng Ng If Ng Ng Include ❯