I’m new to JavaScript, and was wondering if there is a way to check where the focus was before the user pressed the Enter button. I want to process things differently based on the focus. Any ideas?
Share
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 guess that based on the focus means that if the user presses enter on an input you want to do one thing, and if the user presses enter into another input do something else.
if I am right, you don’t have to check where the focus was. You want to bind functions to the onkeypress event.
the above code its very basic, but it’s only for you to get the idea.
more info here: http://www.w3schools.com/jsref/event_onkeypress.asp