Keybord control for scripts
squeak-dev at lists.squeakfoundation.org
Sun Oct 27 21:51:07 UTC 2002
Hi. A better attempt is at:
and a project at Bobs Super Swiki using it:
Bert Freudenberg wrote:
> did anybody implement keyboard controls for EToys? I'm only aware of Karl
> Ramberg's attempt (http://swiki.gsug.org/sqfixes/2629.html) but I need
> something that can cope with multiple keys.
The latest can do multiple keys.
What's 'missing' is a key type. I use askii numbers whitch is not
> If nobody has done it I would add a method to the Player for PasteUpMorph
> that allows to test whether a certain key is pressed:
> Test [Playfield isKeyDown: #LeftArrow]
> Yes Car turnLeft: 1
> No Test [Playfield isKeyDown: #RightArrow]
> Yes Car turnRight: 2
> No ...
In my enhancement you add a script to the object you want to recive
keystroke. Then you can either trigger scripts with 'keystroke'
or 'ticking'. 'Ticking' will give you the same keystroke over and over
till you press an other one.
Look at the project for how I used the enhancement.
> I'm not quite sure where the actual event handling code should be located.
> A key-down event would add the key code to the set of currently pressed
> keys, key-up events removes it. The set should be rather global, like
> perhaps in the hand? Maybe the hand could generally maintain a set of
> currently pressed keys?
I figured out how to use the events system after som nice tips from Ned
> A more comfortable way of handling keys might be to trigger a script while
> a certain key is pressed, but that would need more fiddling with the
> scripting system I guess.
> Has anybody had similar thoughts? Ideas?
I think my enhancement does what you want.
More information about the Squeak-dev