« Return to Thread: Detecting keyboard state / finding older fixes

Re: Detecting keyboard state / finding older fixes

by Bert Freudenberg :: Rate this Message:

Reply to Author | View in Thread

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 -



_______________________________________________
Beginners mailing list
Beginners@...
http://lists.squeakfoundation.org/mailman/listinfo/beginners

BertsKeys.st.gz (694 bytes) Download Attachment

 « Return to Thread: Detecting keyboard state / finding older fixes