I have one text input and one button (see below). How can I use JavaScript to trigger the button\'s click event when the Enter key is pressed ins
Make the button a submit element, so it'll be automatic.
Note that you'll need a element containing the input fields to make this work (thanks Sergey Ilinsky).
It's not a good practice to redefine standard behaviour, the Enter key should always call the submit button on a form.