Eranga Perera
Eranga Perera

Reputation: 938

it is possible to programmatically click arrow keys in javascript or jquery?

I'm trying to click programmatically arrow keys using javascript or jquery. I did not find a proper solution for that. Guys any ideas ? any examples ?

Upvotes: 5

Views: 3659

Answers (2)

Rakesh Gopal
Rakesh Gopal

Reputation: 590

I don't know how to trigger the events on the entire browser. But this is how you can trigger for individual elements on your page.

<body>
    <script>
       leftArrowKey = 37
       upArrowKey = 38
       rightArrowKey = 39
       downArrowKey = 40

       e = jQuery.Event("keydown");
       e.which = leftArrowKey;
       $("myInput").trigger(e);
    </script>

    <object allowScriptAccess="always" id="myInput" ... >
        ...
    </object>
</body>

To send this event to a flash animation, add allowScriptAccess="always" to the Object tag you are using.

Upvotes: 2

Lenny
Lenny

Reputation: 5937

you can trigger click events by doing

$(selector).trigger('click');

Is that what you're looking for? http://api.jquery.com/trigger/

Upvotes: 0

Related Questions