Jump to content

On Pressing Enter Key


raghunathmitte

Recommended Posts

I have a form in which an input text box is given for giving input. and a button is provided in it, when i click the button a javascript code is executed and results are displayed, now can any one help me out how to execute the javascript code when enter key is pressed(i.e. the button should be clicked when enter is pressed)

Link to comment
Share on other sites

I have a form in which an input text box is given for giving input. and a button is provided in it, when i click the button a javascript code is executed and results are displayed, now can any one help me out how to execute the javascript code when enter key is pressed(i.e. the button should be clicked when enter is pressed)
Have you tried the onkeypress event?By the way, what event are you using now to execute the javascript code when the button is clicked?
Link to comment
Share on other sites

firefox "clicks" a button when enter is pressed on a focus button.here is a simple way to dupe the click for enter key on same element:where input is the element object you want to bind.

input.onkeyup = function (e) {   if(!e){ e = window.event; }  if (e.keyCode==13 ){  input.onclick() ; return true;  } 		 }

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...