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


Groups > comp.soft-sys.math.mathematica > #13090 > unrolled thread

Dynamically updated CurrentValue: I want to know which key is being pressed?

Started byBrentt <brenttnewman@gmail.com>
First post2013-01-11 02:38 +0000
Last post2013-01-15 04:28 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  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

#13090 — Dynamically updated CurrentValue: I want to know which key is being pressed?

FromBrentt <brenttnewman@gmail.com>
Date2013-01-11 02:38 +0000
SubjectDynamically updated CurrentValue: I want to know which key is being pressed?
Message-ID<kcntv9$f8j$1@smc.vnet.net>
Is there a way to get information with CurrentValue of about which key is
being pressed? CurrentValue only seems to have ways to get mouse buttons
and modifier key events---which seems odd, I feel like that's going halfway
with the sort of functionality CurrentValue could provide and I figure I
must be missing something?

[toc] | [next] | [standalone]


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

Fromawnl <awnl@gmx-topmail.de>
Date2013-01-12 03:24 +0000
SubjectRe: Dynamically updated CurrentValue: I want to know which key is
Message-ID<kcql13$lrl$1@smc.vnet.net>
In reply to#13090
Hi,

> Is there a way to get information with CurrentValue of about which key is
> being pressed? CurrentValue only seems to have ways to get mouse buttons
> and modifier key events---which seems odd, I feel like that's going halfway
> with the sort of functionality CurrentValue could provide and I figure I
> must be missing something?

I think you are looking for "EventKey":

EventHandler[Graphics@Rectangle[], {
   "KeyDown" :> Print[CurrentValue["EventKey"]]
   }]

hth,

albert

[toc] | [prev] | [next] | [standalone]


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

FromAlexey Popkov <lehin.p@gmail.com>
Date2013-01-14 05:00 +0000
SubjectRe: Dynamically updated CurrentValue: I want to know which key is
Message-ID<kd03e8$6dh$1@smc.vnet.net>
In reply to#13115
On Saturday, January 12, 2013 7:24:19 AM UTC+4, awnl wrote:
> Hi,
> 
> 
> 
> > Is there a way to get information with CurrentValue of about which key is
> 
> > being pressed? CurrentValue only seems to have ways to get mouse buttons
> 
> > and modifier key events---which seems odd, I feel like that's going halfway
> 
> > with the sort of functionality CurrentValue could provide and I figure I
> 
> > must be missing something?
> 
> 
> 
> 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?

Sincerely,
Alexey

[toc] | [prev] | [next] | [standalone]


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

Fromawnl <awnl@gmx-topmail.de>
Date2013-01-15 04:28 +0000
SubjectRe: Dynamically updated CurrentValue: I want to know which key is
Message-ID<kd2ltu$cop$1@smc.vnet.net>
In reply to#13133
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web