Catch key press at page level

  • Thread starter Thread starter Jinsong
  • Start date Start date
J

Jinsong

Is there a way that I can catch the key press at page (form) level? I
have a page with about 15 controls. but there is only one submit
button. I want to do form submit when user press the enter button.

thanks
 
Hi,

In the body tag of your page add this:

onkeypress="CheckLoginSubmit();"

Then put this in the <head> section of your page:

<script language="javascript">
function CheckLoginSubmit() {
if (event.keyCode == 13) {
document.getElementById("btnLogin").focus();
}
}
</script>

Now, when the Enter key is hit it will switch focus to the button and cause
a submit. Good luck! Ken.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top