Suppose you have a login form and you want to send the form when user press enter on his keyboard and not only by clicking on the submit button.
This can be achieved capturing a specific event when the user is typing. We have to capture the keypress event and listen to trigger an action when the enter key is pressed.
The “evt” and “thisObj” parameters return the event handler and the object (the input type) that made the call to the function. The event parameter is important, the object that calls the fnction is not important as parameter since it’s used only to blur the input field.
This is the html form with the “onkeypress” listener:
<form id='formlogin' action='file.php' method='post'> <input type='text' name='username' /> <input name='pass' type='password' onkeypress="submitonenter('formlogin',event,this)" /> <input type='submit' value='login'/> </form>