Sometimes it’s the simple things that are difficult. For example … while developing an ASP.NET web application it became necessary to catch the enter key and cause a page submit button click event to fire. There is code behind that must execute when the page is submitted. The enter key functionality just improves users experience. So how to implement …
After a couple of hours searching around and testing various options I found the following works perfectly. Just add to the page body tag and replace “btLogin” with your button name.
onkeydown=”if(event.keyCode == 13){document.getElementById(‘btLogin’).click();}”
The credit for this code snippet goes to the jsckol’s den.