AngularJS – ng-keydown Directive

The ng-keydown directive in AngularJS basically specifies a custom event on pressing the key. We can perform multiple functions whenever the keydown event is called. This event also supports different types of elements like input>, select> and textarea>.

Syntax

..content..

Example − ngKeydown Directive

Create a file "ngKeydown.html" in your Angular project directory and copy-paste the following code snippet.


   
      ngKeydown Directive

      

      
      

      
      

         Welcome to Tutorials Point      

         

            AngularJS | ngKeydown Directive      

     
         Enter Name:          
     
   

Output

To run the above code, just go to your file and run it as a normal HTML file.

On keyDown −


Example 2

Create a file "ngKeydown.html" in your Angular project directory and copy-paste the following code snippet.


   
      ngKeydown Directive

      

      

      
      

         Welcome to Tutorials Point      

         

            AngularJS | ngKeydown Directive      

     
                   key down count: {{count}}      
   

Output

To run the above code, just go to your file and run it as a normal HTML file.

Will count the occurrence of keydown events −

Updated on: 2021-10-08T09:20:38+05:30

413 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements