VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-keydown-directive/

⇱ AngularJS ng-keydown Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-keydown Directive

Last Updated : 11 Jul, 2025

The ng-keydown Directive in AngluarJS is used to apply custom behavior on a keydown event. This directive will not be overridden by the element's original onkeydown event. Both the onkeydown event & the ng-keydown Directive will be executed. It is supported by <input>, <select> and <textarea> elements.

Syntax:

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

Parameter:

  • expression: It specifies the expression will be executed when the key is pressed.

Example: This example uses the ng-keydown Directive to change the background color after pressing the button. 

Output:

👁 Image
 

Example 2: This example uses the ng-keydown Directive to change the font-size when the key down button is pressed.

Output:

👁 Image
 
Comment

Explore