How to detect shift down

Andreas Raab Andreas.Raab at
Wed Apr 24 09:27:55 UTC 2002

> > 	ActiveEvent shiftPressed.
> That still doesn't seem to work.  The code I put this in (before a
> halt) never halted, though I sat on the shift key.  When I test in a
> workspace (Delay forSeconds: 1) wait. ActiveEvent
> is always true, but shiftPressed is always false.  One possible
> explanation is that the relevant event is the one causing the
> evaluation (alt-p). 

Well, yes, of course! ActiveEvent is the event that is currently handled
so if you hit Alt-P it's gonna be Alt-P ;-) What else would you expect?

> But at any rate I still can't get a hold of the
> current keyboard state.

Then, maybe you should explain where you need to use it. It appears to
me that if you are in some Morphic environment ActiveEvent will give you
exactly what you'd expect. As an example, you might try to select
	ActiveEvent shiftPressed.
then right-click to get the context menu, then press the shift key, and
release the mouse over the "printIt" entry. It should say "true" as a
result (at least it does so on my machine).

  - Andreas

More information about the Squeak-dev mailing list