Ng-Keydown-7

 

For true value of keyDown variable ng-class keyDown will apply.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <style> .keyDown { background-color: red; } </style> </head> <body ng-app> <div> Text: <input type="text" ng-model="text" ng-class="{true:'keyDown'}[keyDown]" ng-keydown="keyDown=true" /><br /> </div> </body> </html>
Output