[R-gui] Ask for the State of a Keyboard Key

Adrian Waddell adrian at waddell.ch
Thu Jun 24 20:17:56 CEST 2010


Dear GUI list,

Is it possible in R to check whether a certain key is pressed or not.

For example

if(isKeyPressed("a")) {
   cat("a is pressed\n")
}else {
   cat("a is not pressed\n")
}

I would like to use this function within tk events. For example when a 
'<Button-1>' event calls foo(), I would like to know within foo() 
whether the Shift key is pressed or not.

I know that I could generate events when a key is pressed or released 
(with focus on a tk toplevel window). However I would prefer a function 
like isKeyPressed().

Sincerely,

Adrian Waddell



More information about the R-SIG-GUI mailing list