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>

2 comments:

  1. I love this. It is soo informative. Are you also searching for cheap assignment writing services we are the best solution for you. We are best known for delivering the best services to students without having to break the bank

    ReplyDelete
  2. Good blog. Keep sharing. I love them Are you also searching for Cheap assignment help? we are the best solution for you. We are best known for delivering cheap assignments to students without having to break the bank

    ReplyDelete

Blogroll

Follow this blog by Email

Popular Posts