I have a page with two button. When I press ‘5’ I want that button1 to be clicked and on pressing ‘6’ Button 2 to be clicked. Is it possible using jQuery?
Can I also handle Ctrl+5 in jQuery?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I recommend binding to the keyup event to prevent event duplicate firings. Here’s some sample assuming buttons with Ids, button1 and button2.
Trapping CTRL+5 is very tricky and in the case of Chrome, it is intercepted by the browser.