Mohammad Ghazi Istanboli Mohammad Ghazi Istanboli - 1 month ago 6
jQuery Question

Are the indexes for keyboard keys united in all programming languages?

Hello guys am wondering if there is a unite set of indexes for keyboard shortcuts am trying to perform specific actions when a specific key is pressed in JQuery I know the syntax here is my code :

//Jquery

$(document).ready(function(){

$("#animation").keydown(function(event){
if(event.which == 13)
$("#animation").stop();
});

});


now the question is the number 13 means "Enter" just in JQuery or its a windows standard either case please supply me with a list of indexes for keyboard keys. Thanks in advance.

Answer

here is a list of some handy keys with the functions ready to use. and yes the indexes are unique .. and you can easily find any key code here to use

    $(window).keydown(function(e){
          
        if(e.keyCode==49 )//1   
        {    
        }

        else if(e.keyCode==50 )//2
        {    
        }
        else if(e.keyCode==51 )//3
        { 
        }
        else if(e.keyCode==52 )//4
        { 
        }
        else if(e.keyCode==53 )//5
        { 
        }
        else if(e.keyCode==54 )//5
        { 
        }
        else if(e.keyCode==81)//q
        {

        }
        else if(e.keyCode==13)//enter
        {
             
        }
                
        else if(e.keyCode==38|| e.keyCode==33)//up
        { 
           
        }
        else if(e.keyCode==40|| e.keyCode==34)//down
        { 
            
        }
        else if(e.keyCode==39)//right
        { 

        }
        else if(e.keyCode==37)//left
        {
             
        }
        else if(e.keyCode==36)//home
        { 
        }
        else if(e.keyCode==35)//end
        { 
        }
        else if(e.keyCode==27)//Esc
        {
            
        }
    });

Comments