We can find which key is pressed using keypress event. Pass $event to the function. We can track the pressed key using $event.keyCode. Read about key codes over here

Type Here <br/>
<input type="number" ng-keypress="whichKey($event)"/>
<script>
function myCtrl($scope, $compile) {
    $scope.whichKey = function($event) {
       if($event.keyCode == 13) {
         alert('Enter pressed');
       } else if($event.keyCode == 8) {
         alert('Backspace pressed');         
       } else if($event.keyCode == 9) {
         alert('Tab pressed');         
       } else if($event.keyCode == 32) {
         alert('space pressed');         
       } else {
         alert($event.keyCode);
       } 
    };
}
</script>

0 comments:

Blogroll

Follow this blog by Email

Popular Posts