MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Dynamically updated CurrentValue: I want to know which key is

  • To: mathgroup at
  • Subject: [mg129454] Re: Dynamically updated CurrentValue: I want to know which key is
  • From: awnl <awnl at>
  • Date: Mon, 14 Jan 2013 23:31:45 -0500 (EST)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <kcntv9$f8j$> <kcql13$lrl$> <kd03e8$6dh$>

>> I think you are looking for "EventKey":
>> EventHandler[Graphics@Rectangle[], {
>> "KeyDown" :> Print[CurrentValue["EventKey"]]
>> }]
>> hth,
>> albert
> But why not all keys are catched by "EventKey"? For example, pressing
> "a", "i", "o", "p" etc. does nothing. Why?

I don't know what exactly is the reason why it doesn't work for you. I 
can see three possible causes:

1) There are built in keyboard shortcuts which "eat up" what you type 
before the EventHandle will even see them, typical examples are things 
like Ctrl-C on Windows. Unfortunately I don't think there is a 
documented way to change that.

2) Many of the keys are only giving None for CurrentValue["EventKeys"], 
presumably WRI only has implemented the smallest common set available on 
all supported OS...

3) The selection state is not what it should be. With that respect my 
example using a Graphics is suboptimal as it needs some tricks to 
actually select the EventHandler and not the Graphics object. You might 
want to use something like EventHandler["hello", {"KeyDown" :> 
Print[CurrentValue["EventKey"]]}] instead, where putting the cursor 
within the hello does the right thing...

The following makes the Graphics example somewhat easier to use (just 
clicking into the graphic will make the selection such that the keyboard 
events are catched by the EventHandler):

   Selectable -> False], {"KeyDown" :>



  • Prev by Date: Iterative process for creating a B Spline Curve points
  • Next by Date: kalman filter understanding - one measurement two variables
  • Previous by thread: Re: Dynamically updated CurrentValue: I want to know which key is
  • Next by thread: Aligning graphics on frame boundaries