[R] Wait for keystroke or timeout

Greg Snow Greg.Snow at imail.org
Fri May 28 18:16:50 CEST 2010


This is really a user interface issue and the standard user interface is different between platforms.  Would tcltk (or RGTK or ...) be a possible solution for you?  tcltk is fairly consistent across platforms and does provide for this type of thing (you can have a button to press to continue and use the after function to send an automatic push if the user does not push it before a given time).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Prof. John C Nash
> Sent: Thursday, May 27, 2010 5:09 PM
> To: r-help at r-project.org
> Subject: [R] Wait for keystroke or timeout
> 
> I would like to have a function that would wait either until a
> specified timeout (in
> seconds preferably) or until a key is pressed. I've found such a
> function quite useful in
> other programming environments in setting up dialogs with users or
> displaying results,
> rather like a timed slideshow that can be speeded up by hitting a key.
> 
> Searching R-seek has led to wait() in the package 'audio', but when I
> try, for example,
> 
>     joe<-wait(readline("hit a key to continue"), timeout=6)
> 
> I am forced to wait the full timeout.
> 
> Probably someone has done this before and I'm just not using the right
> search terms.
> Suggestions welcome.
> 
> Thanks in advance.
> 
> JN
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list