Several times I have wanted to detect single keystrokes in R but have failed to find anything else than readline()
or similar.
An example would be to do interactive plotting or data browsing and be able to change parameter values with the arrow keys and automatically update the plot. Of course I could use readline()
and have the user input "u" then instead of up arrow but I don't find it very elegant.
Could it be done with a system()
command reading stdin in some way?
EDIT: I have now been told elsewhere that stdin also wait for an enter-stroke before doing anything and that catching keystrokes immediately is system specific and tricky to accomplish. If anyone knows how to do it on ubuntu 10.10 or any other Linux/unix system I'd be glad to know.