Reputation: 8329
I have a UI with a button, i want the button to take the click on pressing the Enter key?
Upvotes: 1
Views: 960
Reputation: 807
if(event.which || event.keyCode) {
if ((event.which == 13) || (event.keyCode == 13)) {
document.getElementById('buttonID').click();
return false;
}
}
else {
return true;
}
Upvotes: 4