I've got a stand-alone input field, not part of any form.
I also got a button, that has some onclick event.
When I type something in the input field, and press the Enter key, I want it do effectively press the button, or trigger its onclick event. So that the button is "the input field's default button" so to speak.
<input id='myText' type='text' />
<button id='myButton' onclick='DoSomething()'>Do it!</button>
I guess I can mess around with the input field's onkeypress or onkeydown events and check for the Enter key, etc.
But is there a more 'clean' way, I mean something that associated the button with that input field, so that the button is the 'default action' or something for that field?
Note that I'm not inside a form, I am not sending, posting, or submitting something. The DoSomething() function just changes some of the HTML content locally, depending on the text input.