Ng-Keydown-5

 

On ng-keydown directive KeyDown value is set to true.For true value of expression KeyDown class is apply otherwise keyUp class is apply.

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