MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 297

Actionscript language reference
Table of Contents

Advertisement

myListener.onKeyUp = function () {
trace ("You released a key.");
}
Key.addListener(myListener);
The following example assigns the keyboard shortcut Control+7 to a button with an instance
name of
my_btn
). In this example, when you press Control+7 the
_accProps
"hello" to the log file.
function myOnPress() {
trace("hello");
}
function myOnKeyDown() {
// 55 is key code for 7
if (Key.isDown(Key.CONTROL) && Key.getCode() == 55) {
Selection.setFocus(my_btn);
my_btn.onPress();
}
}
var myListener:Object = new Object();
myListener.onKeyDown = myOnKeyDown;
Key.addListener(myListener);
my_btn.onPress = myOnPress;
my_btn._accProps.shortcut = "Ctrl+7";
Accessibility.updateProperties();
See also
Key.getCode(), Key.isDown(), Key.onKeyDown, Key.onKeyUp,
Key.BACKSPACE
Availability
Flash Player 5.
Usage
Key.BACKSPACE:Number
Description
Property; constant associated with the key code value for the Backspace key (8).
Example
The following example creates a new listener object and defines a function for
last line uses
addListener()
notification from the key down event.
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.BACKSPACE)) {
trace("you pressed the Backspace key.");
} else {
trace("you DIDN'T press the Backspace key.");
}
and makes information about the shortcut available to screen readers (see
to register the listener with the Key object so that it can receive
function writes the text
myOnPress
Key.removeListener()
onKeyDown
Key.BACKSPACE
. The
297

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents