Jump to content


Photo

onkey... event key capture


  • Please log in to reply
4 replies to this topic

#1 Goose

Goose
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts
  • LocationOregon

Posted 11 October 2006 - 06:57 PM

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:

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

The move_to_next() function checks the this 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.

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

Thanks in advance.

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 11 October 2006 - 07:13 PM

check out this article on capturing keystrokes. if you couple this with what you're already doing, i'm sure you can come up with a workable solution ;)
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 Goose

Goose
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts
  • LocationOregon

Posted 11 October 2006 - 07:28 PM

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.

#4 Goose

Goose
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts
  • LocationOregon

Posted 11 October 2006 - 07:38 PM

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....keystrokes.html

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 11 October 2006 - 11:01 PM

IE has an global event object that has keyCode... no idea about FF.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users