By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,173 Members | 1,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,173 IT Pros & Developers. It's quick & easy.

trigger HTML button by enter ENTER key

P: n/a
<input type="button" onClick="doSomething()">

When the user click HTML button, it will launch doSomething(). But I
want the user enter ENTER key, it will have same effect.

Please advise. Thanks!
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 6 Mar 2004 08:12:38 -0800, Matt <jr********@hotmail.com> wrote:
<input type="button" onClick="doSomething()">

When the user click HTML button, it will launch doSomething(). But I
want the user enter ENTER key, it will have same effect.


If the button has focus, pressing enter will invoke an onclick event. If
some other control (in a form) has focus, the form's submit button will
receive the event.

As I see it, if you do want to invoke an event on an arbitrary control,
you'll have to handle the onkeydown event on *every* control that might be
active when Enter is pressed and fire the event yourself. That's a lot of
work.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.