A feature that I would really like to see implemented on all HTML forms is the ability to submit the form by using the Return key as well. I am sure that there are a lot of users who really like to keep their hands on the keyboard as much as possible, without using the mouse just to click a button or without hitting the TAB key in order to focus on the submit button after which to press Return. Some of the particularities of my project are the fact that it uses Struts2 and the Struts2 jQuery plugin. This plugin allows developers either to use the
The code responsible for the issue is the following:
1 2 3 4 5 6 7 8 9 10 11 12 13
What I have discovered is that the
.click() handler actually binds itself to keyboard events too, not only mouse events. This means that if the user presses the Return button the event will be identified with a click event.
Even though if the behaviour mentioned previously is unexpected (who would have thought that a click event would be triggered by the keyboard even if the focus is not set on the submit button?!), there are two ways of avoiding it in the code above:
.keyup()handler because pressing on the Return button will be considered a click event;
alter the first bind for the
.click()handler like this:
1 2 3 4 5 6
Have you ever had similar problems?