You need to use a form. Pressing enter or return when focused on a form element submits the form, triggering the onsubmit event, if there is one, and the action attribute, if there is one. Change your button to type=submit. Change the form's onsubmit to the name of the function you're calling when you press the button.
HTH,
Snib
<><