Jump to content

Archived

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

Goose

onkey... event key capture

Recommended Posts

I am using a couple different onkey... event listeners in Javascript, i.e. onkeyup. When I hit some of these event listeners I want to know which key was actually hit. Here is my code now:

[code]
<input type="text" ... onkeyup="move_to_next(3, this, 'next_item_id');" />
[/code]

The move_to_next() function checks the [i]this[/i] element and if the length equals the first argument then it puts the focus on the element with the id of the last argument. What I really want to do now is conditionally move the focus depending on which keys are hit.

[b]Is there a way for me to pass which key was hit to my move_to_next() function?[/b]

Thanks in advance.

Share this post


Link to post
Share on other sites
check out [url=http://www.breakingpar.com/bkp/home.nsf/0/CACEB633F995E9CE87256AFB00141646]this article[/url] on capturing keystrokes. if you couple this with what you're already doing, i'm sure you can come up with a workable solution ;)

Share this post


Link to post
Share on other sites
So far I  haven't had any luck implementing this. If you can show me a working example that would be awesome. This site sort of explains the idea, but it would be really helpful, for me, to see how it is implemented.

Thanks. I am going to continue trying to make this work.

Share this post


Link to post
Share on other sites
I guess I was searching for the wrong terms in google before I posted here because I wasn't getting good hits, but this time around I was much more successful. Basically this site has some semi-working functions that I think I can clean up and make work:

http://www.mark-itt.ru/docs/dynamic_duo/keystrokes/keystrokes.html

Share this post


Link to post
Share on other sites
IE has an global event object that has keyCode... no idea about FF.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.