Keyboard Tasks

Table 10-10 shows the handler(s) and scripts(s) used to accomplish common tasks related to the keyboard. The trick is to place the correct type of handler in the correct type of script, so that it will be called when the event of interest occurs.

Table 10-10. Common Keyboard Tasks

To Detect

Use This Type of Handler or Property

In This Type of Script

Keyboard input for all sprites using a particular cast member

on keyDown

Castmember script

Keyboard input for a sprite

on keyDown

Sprite script

Keyboard input ignored by all sprites in a frame

on keyDown

Frame script

Keyboard input throughout the entire movie otherwise ignored by other scripts

on keyDown

Movie script

All keyboard input before it is passed to individual sprites or frames.

set the keyDownScript

Place primary event handler in movie script

Keyboard input from numeric keypad

on keyDown

Sprite or cast member script

Key being pressed at any time

set the keyDownScript

Place primary event handler in movie script

Key being released at any time

set the keyUpScript

Place primary event handler in movie script

Modifier keys

Check the commandDown, controlDown, optionDown, or shiftDown property

Any

The last key pressed

Check the key, keyPressed, keyCode property

Any

Whether a specific key is pressed

Use third-party Xtras described under "Keyboard Xtras" later in this chapter

Any

See "Keyboard Focus" earlier in the chapter to force keyboard focus on a sprite.There is no easy ...

Get Lingo in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.