Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13144

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

From awnl <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Dynamically updated CurrentValue: I want to know which key is
Date 2013-01-15 04:28 +0000
Message-ID <kd2ltu$cop$1@smc.vnet.net> (permalink)
References <kcntv9$f8j$1@smc.vnet.net> <kcql13$lrl$1@smc.vnet.net> <kd03e8$6dh$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Hi,
>>
>>
>> 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):

EventHandler[
  Style[Graphics[Rectangle[]],
   Selectable -> False], {"KeyDown" :>
    MessageDialog[CurrentValue["EventKey"]]}
  ]


hth,

albert

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Dynamically updated CurrentValue: I want to know which key is being pressed? Brentt <brenttnewman@gmail.com> - 2013-01-11 02:38 +0000
  Re: Dynamically updated CurrentValue: I want to know which key is awnl <awnl@gmx-topmail.de> - 2013-01-12 03:24 +0000
    Re: Dynamically updated CurrentValue: I want to know which key is Alexey Popkov <lehin.p@gmail.com> - 2013-01-14 05:00 +0000
      Re: Dynamically updated CurrentValue: I want to know which key is awnl <awnl@gmx-topmail.de> - 2013-01-15 04:28 +0000

csiph-web