Is there really a way with which i could count the number of times, the enter key is pressed in a webpage. Not within an element say, a text box for an example, but rather the whole webpage. say if i open google.com and type something in the search box and hit enter, so the count is one. as such, another search would give 2 enters pressed.any suggestions or ideas?
            Asked
            
        
        
            Active
            
        
            Viewed 1,265 times
        
    -2
            
            
        - 
                    `java` + `jquery`? Maybe you mean `javascript`? Remember, [`java` is not `javascript`](http://stackoverflow.com/questions/245062/whats-the-difference-between-javascript-and-java). – u32i64 Mar 06 '17 at 15:29
- 
                    Sure it is possible. But out of interest: Why would you want to count the times enter is pressed? Does the first user to press enter 100times on your site win a price? ;-) – OH GOD SPIDERS Mar 06 '17 at 15:31
- 
                    add a counter for everytime someone searches i'd say. – SC92 Mar 06 '17 at 15:31
2 Answers
0
            
            
        You can achieve this by using following approach:
var noOfCounts = 0;
$(document).on('keyup', function(e){
    if (e.which == 13){
        noOfCounts ++;
    }
});
 
    
    
        Muhammad Qasim
        
- 1,622
- 14
- 26
 
    