Re: [R] tkbind key pressed

From: Peter Dalgaard <>
Date: Sat 10 Dec 2005 - 09:51:59 EST

"Manel Salamero" <> writes:

> Hi,
> I see in Wettenhall RTclTk Examples that tkbind(xxx, <Key>,...) can
> pass the key pressed. How can I get the key pressed?

By making the callback function have an argument with a specific name. Lookup the %-codes in the Tk man page for "bind". There are multiple codes for getting the key as keycode, keysym, Unicode character,... E.g.

    %K The keysym corresponding to the event, substituted as a textual

         string. Valid only for KeyPress and KeyRelease events.

so if you declare your callback to be

f <- function(K) print(K)

the keysym should be printed to the console.

[actually. that might be print(tclvalue(K)) --- I forget whether these arguments are passed as tclObj's.]

   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (                  FAX: (+45) 35327907

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Sat Dec 10 10:04:04 2005

This archive was generated by hypermail 2.1.8 : Sat 10 Dec 2005 - 14:29:21 EST