Re: Repeated keypress/keydown event

Wizz
2007-11-14T10:14:56Z

Keydown should be the event you are looking for...

Event.observe(window, ''keydown'', function(ev) {
  var key = (window.event) ? window.event.keyCode : ev.which;

  switch(key) {
    case Event.KEYUP:
      this.moveUp();
      break;
    case Event.KEYDOWN:
      this.moveDown();
      break;
  }
}.bind(this));

the window will keep firing this event as long as the key is pressed
so it will keep calling the moveDown-method. If you keep a reference
within your js object to the current selected item, you should be able
to take it from here...

On Nov 13, 1:37 pm, Matt <mlro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> Hi all
>
> I''ve implemented a typeahead/live search widget and currently
allow
> iteration through the dropdown list using the arrow keys.
>
> At the moment, the selection only moves once each time the arrow
> button is pressed (keydown).
>
> Is it possible to keep iterating through the items in the dropdown for
> as long as the key is held down?
>
> Example:http://www.google.com/webhp?complete=1&hl=en
>
> Many thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---