[Squeakland] fire a script with a keypress
Ned Konz
ned at bike-nomad.com
Sun Dec 4 23:04:26 PST 2005
On Dec 4, 2005, at 12:48 AM, karl wrote:
> Bert Freudenberg wrote:
>
>> Am 03.12.2005 um 18:26 schrieb karl:
>>
>>
>>
>>> Bob Irving skrev:
>>>
>>>
>>>
>>>> Can anyone tell me how to fire a script with a keypress in eToys?
>>>> For instance, how could you use the space bar to pause? Just an
>>>> example.
>>>>
>>>>
>>> Here is a workaround:
>>> The world / background captures keypresses. Bring up a viewer on
>>> the world and select the
>>> input category.
>>> Make a script like the the one in the attachment picture.
>>>
>>>
>>
>> Better yet, do not set the script to ticking, but to be activated on
>> keystroke.
>>
>> - Bert -
>>
> I don't see that choice in the menu
That's in the "more..." menu.
Note that this lets you trigger a script on a key *stroke* -- that
is, a press (and maybe release) of a key that is turned into a
(possibly modified) character.
It doesn't let you sense press/release separately, or key up events.
But it was the simplest thing that could possibly work, and no one
has come up with anything much fancier that I know of.
I did make it so you could sense some special keys (grab a viewer for
"World's lastKeystroke"):
"A" (shift+a)
"a"
"<Ctrl-a>"
"<Ctrl-Shift-a>"
"<Opt-å>" (option or alt key + a) (probably "<Opt-a>" on a windows
machine)
"<Ctrl-Opt-a>"
As well as some other keys:
<right>
<left>
<up>
<down>
<pageUp>
<pageDown>
<home>
<end>
etc.
Note that if a text field or morph has the keyboard focus, it'll eat
the keystroke and the World won't see it.
Ned
More information about the Squeakland
mailing list