[Newbies] Detecting keyboard state / finding older fixes

Bert Freudenberg bert at freudenbergs.de
Tue Mar 4 21:01:43 UTC 2008

On Mar 4, 2008, at 19:19 , stan shepherd wrote:

> handleKeyUp: anEvent
> 	Transcript show: ' evt is down ',anEvent isKeyDown asString; cr.
>         "now press and hold a key"
> shows
>  evt is down false

Which is of course expected since only keyUp events are passed into  
#handleKeyUp:, so #isKeyDown always is false.

You need to handle both keyDown and keyUp events, and track the state  
of pressed keys.

Note that the keyValue in up/down events is system-specific (unlike  
keyStroke events which have actual characters).

Also note that this behavior also depends on your OS and VM version.  
The Windows VM handles up/down events nicely for a long time, Mac VMs  
since recently, Unix VMs are broken I think.

I'm attaching a small example morph demonstrating this.

- Bert -

-------------- next part --------------
A non-text attachment was scrubbed...
Name: BertsKeys.st.gz
Type: application/x-gzip
Size: 506 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080304/e5c0ba22/BertsKeys.st.bin

More information about the Beginners mailing list