Forum: Ruby on Rails How to react to a key press in rjs file?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Af118fdefb3fa098fb06b167d479e5d8?d=identicon&s=25 Christopher (Guest)
on 2008-10-29 16:01
(Received via mailing list)
Hi everybody,

I'm a rails beginner and I'm trying to figure out how to react to a
keyboard press in an rjs-file and then do some stuff to the page. It
should go something like this:

if @correct
  #do something
  #wait for the user to press any key
    #do something

Does anybody know how to do this?

Thanks in advance!
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-29 16:08
(Received via mailing list)
On 29 Oct 2008, at 14:40, Christopher wrote:

>    #do something
>  end
> end
> Does anybody know how to do this?

That's not really how event handling is done in javascript. you would
normally attach an event handler to some page object rather than sit
and wait for an event to happen.

This topic is locked and can not be replied to.