Keybord control for scripts

Bert Freudenberg bert at isg.cs.uni-magdeburg.de
Sun Oct 27 21:19:02 UTC 2002


Hi,

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.

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 ...

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?

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?

-- Bert




More information about the Squeak-dev mailing list