EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - CONTROL (Key.control Property)

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
674 ActionScript classes
Example
The following example creates a new listener object and defines a function for
onKeyDown.
The last line uses
addListener() to register the listener with the Key object so that it can
receive notification from the key down event.
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.CAPSLOCK)) {
trace("you pressed the Caps Lock key.");
trace("\tCaps Lock == "+Key.isToggled(Key.CAPSLOCK));
}
};
Key.addListener(keyListener);
Information is displayed in the Output panel when you press the Caps Lock key. The Output
panel displays either
true or false, depending on whether the Caps Lock key is activated
using the isToggled method.
CONTROL (Key.CONTROL property)
public static CONTROL : Number
The key code value for the Control key (17).
Availability: ActionScript 1.0; Flash Player 5
Example
The following example assigns the keyboard shortcut Control+7 to a button with an instance
name of
my_btn and makes information about the shortcut available to screen readers (see
_accProps). In this example, when you press Control+7 the myOnPress function displays the
text
hello in the Output panel.
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();

Table of Contents

Related product manuals