Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2008

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

Search the Archive

Re: waiting for pressed key and reading key

  • To: mathgroup at
  • Subject: [mg87614] Re: [mg87570] waiting for pressed key and reading key
  • From: Pratik Desai <pratikd at>
  • Date: Mon, 14 Apr 2008 05:45:47 -0400 (EDT)
  • References: <>

On Sun, 13 Apr 2008, 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.

Hello Adrian,

Perhaps this is not what you are exactly looking for but using 
CurrentValue might be the way to go, for example
here pressing Command and Shift causes the Disk to change to Circle.

      If[CurrentValue["ShiftKey"] && CurrentValue["CommandKey"],
       Style[x = True, White], Style[x = False, White]],
     PaneSelector[{True -> Graphics[Circle[]],
       False -> Graphics[Disk[]]}, Dynamic[x]]}]]

> 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.

Seems like CurrentValue["MouseOver"] might also be useful

    PlotLabel -> If[CurrentValue["MouseOver"], f = Circle, f = Disk]]]


Pratik Desai
Wolfram Research

> Any help is appreciated.
> Thanks,
> Adrian


  • Prev by Date: Re: List concatenation speed
  • Next by Date: Re: List concatenation speed
  • Previous by thread: waiting for pressed key and reading key
  • Next by thread: Re: waiting for pressed key and reading key