I am wondering how to set the default button in html page, so that when enter key is pressed, the same effect of button pressed? For example, when we use Google, after entering query string in the middle input box, we can press enter key to get query results (i.e. press enter has the same effect of click “Google Search” button).
Any solutions? I am not sure whether there are different solutions when it is an html button, and when it is the submit button of a html form?
thanks in advance,
George
That’s simply done with a
<form>element.For example, if you have something like this:
and you press enter in the input field, the form will be posted to something.php, ie. the same as if you press the submit button.