Immediate keyUp events on Mac OS X?

Glen Whitney glen at rentec.com
Fri Apr 9 04:14:49 UTC 2004


I downloaded Squeak from SqueakLand.org a few days ago (my VM says
it is version 3.7.2b1, and I'm running under Mac OS X 10.2.8) and
started to play with the examples on that site. When I tried to make
my own eToys, I was quite disappointed to see that the choices for when a
script could run (normal, paused, mouseDown, etc) did not include
anything to do with keypresses, which would provide a richer interface
for many potential applications. 

Encouraged by some examples on "Bob's Super Swiki" (e.g. a Space War
which accepts keyboard input) and by the accessibility of all of the
Squeak system code, I did a little hacking. I modified PasteUpMorph so it
would always say it handlesKeyboard, and then added keyUp and keyDown
methods which simply call keyUp and keyDown scripts on a specific
Player object I've created (so I can write those scripts with the
eToys tile interface if I like).

But now I find that when I press a key and hold it down, my keyDown
script is called as desired. But the keyUp script is instantly called,
and if I contiue to hold the key down, after a bit the two scripts are
called repeatedly in rapid succession. I tried turning off keyboard
repeat in the System Preferences, which eliminated the repetitve
calls, but still the first keyUp was called instantly after the
keyDown, even though I still had the key down.

It is as if the keyboard repeat and such were being implemented at too
low a level, so that from Squeak's point of view the key really had
been pressed and released, especially since I get the multiple events
when key repeat is on and I hold the key down for a while.

Obviously what I'd like is a single keyDown event when I press and
one keyUp when I release. I tried to search this list but couldn't find
anything relevant, my apologies if I'm being repetitive. Does anyone
know a way to obtain that behavior?

   Thanks so much for any help you can offer,
          Glen Whitney



More information about the Squeak-dev mailing list