f



waiting for pressed key and reading key

Hi everyone,

I am interested to include in a program a part in which the program 
waits until either of two specific keys are pressed, and once this 
happens waiting is over and the one key (ut of the two) which was 
pressed determines the value of a variable. I basically want to use as a 
mean to read user confirmation.
I figured out how to do something in this line by using a DynamicModule, 
with an EventHandler that wait for a mouse click. The problem I have 
with that is that I would prefer to use keys and also that 
"MouseClicked" event requires the cursor to be positioned over a certain 
expression.
Any help is appreciated.

Thanks,
Adrian



-- 
=================================
Adrian Lupascu
Centre National de la Recherche Scientifique 
Laboratoire Kastler Brossel
Ecole Normale Sup´┐Żrieure
24 rue Lhomond
75231 Paris CEDEX 05
Tel: +33 144323304
Fax: +33 144323434
E-mail: Adrian.Lupascu@lkb.ens.fr


0
4/13/2008 7:33:55 AM
comp.soft-sys.math.mathematica 28821 articles. 0 followers. Follow

2 Replies
525 Views

Similar Articles

[PageSpeed] 33

Have you tried to use the KeyDown event with EventHandler?

Also you can do things at the full Notebook level using
NotebookEventActions.  And if you want to get even more Draconian
(i.e., creative) you can use FrontEndEventActions.

I haven't had time to experiment with these for you, but give them a
try...

Hope this helps,

--David

On Apr 13, 3:33 am, Adrian Lupascu <Adrian.Lupa...@lkb.ens.fr> wrote:
> Hi everyone,
>
> I am interested to include in a program a part in which the program
> waits until either of two specific keys are pressed, and once this
> happens waiting is over and the one key (ut of the two) which was
> pressed determines the value of a variable. I basically want to use as a
> mean to read user confirmation.
> I figured out how to do something in this line by using a DynamicModule,
> with an EventHandler that wait for a mouse click. The problem I have
> with that is that I would prefer to use keys and also that
> "MouseClicked" event requires the cursor to be positioned over a certain
> expression.
> Any help is appreciated.
>
> Thanks,
> Adrian
>
> --
> =========================
=========
> Adrian Lupascu
> Centre National de la Recherche Scientifique
> Laboratoire Kastler Brossel
> Ecole Normale Sup=E9rieure
> 24 rue Lhomond
> 75231 Paris CEDEX 05
> Tel: +33 144323304
> Fax: +33 144323434
> E-mail: Adrian.Lupa...@lkb.ens.fr


0
dbreiss (537)
4/14/2008 9:43:55 AM

Hi Adrian,

you may use a "KeyDown" event, e.g. like:

EventHandler["Cursor 

here",{{"KeyDown","a"}:>(var=1;),{"KeyDown","b"}:>(var=2;)}]

hope this helps, Daniel





Adrian Lupascu wrote:

> Hi everyone,

> 

> I am interested to include in a program a part in which the program 

> waits until either of two specific keys are pressed, and once this 

> happens waiting is over and the one key (ut of the two) which was 

> pressed determines the value of a variable. I basically want to use as a 

> mean to read user confirmation.

> I figured out how to do something in this line by using a DynamicModule, 

> with an EventHandler that wait for a mouse click. The problem I have 

> with that is that I would prefer to use keys and also that 

> "MouseClicked" event requires the cursor to be positioned over a certain 

> expression.

> Any help is appreciated.

> 

> Thanks,

> Adrian

> 

> 

> 



0
dh142 (1271)
4/14/2008 9:45:44 AM
Reply: