Handling key events (Flash Professional Only)
13
Handling key events (Flash Professional
Only)
In addition to using tab navigation between buttons and input text fields, a Flash Lite
application can also respond to arbitrary keypress events.
Not all devices and content types support all device keys. For example, on a device that
supports two-way navigation (see
“Modes of tab navigation” on page 9
) Flash Lite doesn’t
generate keypress events for the Left and Right Arrow keys.
On all devices, Flash Lite supports the following keys:
■
0-9, *, and # keys
■
Select key
On devices that support two-way navigation, Flash Lite also supports the Up and Down
Arrow keys on the 5-way keypad. On devices that support four-way navigation, Flash Lite
supports the Up, Down, Left, and Right Arrow keys.
On devices that support the
SetSoftKeys
command, Flash Lite also supports the Left and
Right soft keys.
This section contains the following topics:
Writing a key handler script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Creating a key catcher button (Flash Professional Only) . . . . . . . . . . . . . . . . . . . . . . 14
Creating a simple menu using movie clips (Flash Professional Only). . . . . . . . . . . . 16
Writing a key handler script
To handle a keypress event, you attach an
on(keyPress "
key
")
handler to a button instance,
where
key
is a supported key event name. For example, the following code, attached to a
button instance on the Stage, executes when the user presses the Right Arrow key on
their device:
on(keyPress "<Right>") {
trace("You pressed the right arrow key");
}