I currently have a button with an onclick attribute, directing to a JS function. After I click it with my mouse, pressing the Enter key clicks the button as well, which I want to disable. My button:
<button onclick = "action()">Button</button>
My JS function:
function action(){
//do something
}
I tried solutions from Disable Enter Key and Disabling enter key for form, but they don't work. How do I solve this? Should I not use onclick? I would like a solution in pure JS.