Description Usage Arguments Value Note See Also
Waits until a timer has expired, or the user has provided some input (pressed RETURN)
A message is shown, with a countdown-timer if desired.
1 2 | waitForKey(message = "Continuing in {n} seconds, or press any key.",
time = 10, counter = 0.5, precision = 0.01)
|
message |
Message to be shown during countdown. Use n as a placeholder for the number of seconds left. |
time |
Time to wait, in seconds (approximate) |
counter |
Interval to update the message, in seconds. 0 to remain static. Must otherwise be a multiple of precision to work reliably. |
precision |
Polling interval to use when checking for a keypress. |
(invisibly) Either the string 'key' or 'timer', signifying what caused the return
Unfortunately, does not work on all platforms/in all environments.
It is dependent on being able to read from file('stdin'), which is different from stdin(), see file
for details.
In particular, it does not work in RStudio for MacOS, or Rgui for Windows or MacOS.
It does confirmed work on R run from terminal on MacOS 10.13.6
Problems manifest by file('stdin') not being connected to anything, i.e. no input is received, so this function always returns character(0)
,
and any input typed is interpreted as a new command. To test, try with a small value of time first.
readline_time
for a function that also collects your input.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.