trigger HTML button by enter ENTER key

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    trigger HTML button by enter ENTER key

    <input type="button" onClick="doSome thing()">

    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!
  • Michael Winter

    #2
    Re: trigger HTML button by enter ENTER key

    On 6 Mar 2004 08:12:38 -0800, Matt <jrefactors@hot mail.com> wrote:
    [color=blue]
    > <input type="button" onClick="doSome thing()">
    >
    > When the user click HTML button, it will launch doSomething(). But I
    > want the user enter ENTER key, it will have same effect.[/color]

    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.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    Working...