2

I have a form that I would like to be submitted when you click the tab button on your keyboard. I think I'm doing with my own code... How will I do this?

1 Answer 1

2
myElement.keydown = function (e) {
  if (e.which === 9) myForm.submit();
};

9 is the tab character. I think this is x-browser compatible.

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

3 Comments

myForm is the name of the form? And myElement is what?
You could also use "document.body" instead of "myElement".
myElement is the element you want to want to bind the event to, you may or may not want to bind it to document (the entire page), you could bind it to just an input element by fetching it, such as document.forms.myFormId.elements.myElementId.keydown = .... myForm is the form element, such as document.forms.myFormId

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.