How to detect shift down
Ned Konz
ned at bike-nomad.com
Sat Apr 27 00:19:36 UTC 2002
On Friday 26 April 2002 04:53 pm, Ross Boylan wrote:
> On Wed, Apr 24, 2002 at 11:27:55AM +0200, Andreas Raab wrote:
> So I'm trying to find a way to detect if the shift key is pressed
> at the instanct the method is executing. Does the VM design make
> this difficult (e.g, the shift down is reported as an even, and if
> you aren't in line to catch it you're just not going to find out),
> or am I just missing an easy solution?
The shift state is included in all UserEvents as bit number 3.
(mask=8).
However, the shift events themselves aren't reported; they're just
available as modifier bits on other events.
So if there are no other mouse or keyboard events, you will never see
the shift being pressed, at least in the XWindow port of Squeak.
If you're moving the mouse around or hitting other keys, you'll see
it.
To see them from another thread, you should be able to say Sensor
shiftPressed:
d _ Delay forMilliseconds: 100.
p _ [ [ d wait. Sensor shiftPressed asString displayAt: 20 at 100 ]
repeat ] forkAt: 39
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|