Enter key press behaves like a Tab in Javascript

/ Published in: JavaScript
Save to your folder(s)

This code makes Enter key get the behavior of the Tab Key for forms.

The shift event on the above function to go back between elements.
The reason textarea
is included is because we "do" want to tab into it. Also, once in, we don't want to stop the default behavior of Enter from putting in a new line.

The reason a and button
allow the default action, "and" still focus on the next item, is because they don't always load another page. There can be a trigger/effect on those such as an accordion or tabbed content. So once you trigger the default behavior, and the page does its special effect, you still want to go to the next item since your trigger may have well introduced it.

URL: http://stackoverflow.com/questions/1009808/enter-key-press-behaves-like-a-tab-in-javascript

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.