raghunathmitte Posted December 16, 2008 Share Posted December 16, 2008 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 More sharing options...
lugos Posted December 16, 2008 Share Posted December 16, 2008 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 More sharing options...
rnd me Posted December 16, 2008 Share Posted December 16, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.