0

How can detect the keyboard key down and trigger this line?

$('#submit_p').live('click',function(event){...}

Thanks.

1 Answer 1

3
$(document).keydown(function()){

           if(event.keyCode == 37){  //prev key

                  }else if(event.keyCode == 39){  //next key

                  }else if(event.keyCode == 13){  //enter key
                      $('#submit_p').live('click',function(event){...}  
                  }if(event.keyCode == 27){  //escape key

    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. But how di I assign the <Enter> key?
Edited the answer (i left other keys so you can see more examples, you can just remove others and leave 13 code = ENTER). Happy coding

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.