Categories
HTML

How to stop Enter key from triggering button click with JavaScript?

Spread the love

To stop Enter key from triggering button click with JavaScript, we set the type attribute of the button to button.

For instance, we write

<button type="button">click me</button>

to add a button with type attribute button to stop pressing enter from trigger a button click.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *