Example
The following example creates a new listener object and defines a function for
The last line uses
addListener()
receive notification from the key down event and display information in the Output panel.
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.INSERT)) {
trace("You pressed the Insert key.");
}
};
Key.addListener(keyListener);
isAccessible (Key.isAccessible method)
public static isAccessible() : Boolean
Returns a Boolean value indicating, depending on security restrictions, whether the last key
pressed may be accessed by other SWF files. By default code from a SWF file in one domain
may not access a keystroke generated from a SWF file in another domain. For more
information on cross-domain security, see "Understanding Security" in Learning ActionScript
2.0 in Flash.
Availability: ActionScript 1.0; Flash Player 8
Returns
- The value
Boolean
this method returns
false
isDown (Key.isDown method)
public static isDown(code:Number) : Boolean
Returns
if the key specified in
true
the key code values for the Caps Lock and Num Lock keys are identical.
A Flash application can only monitor keyboard events that occur within its focus. A Flash
application cannot detect keyboard events in another application.
Availability: ActionScript 1.0; Flash Player 5
Parameters
- The key code value assigned to a specific key or a Key class property associated
code:Number
with a specific key.
682
ActionScript classes
to register the listener with the Key object so that it can
if the last key pressed may be accessed. If access is not permitted,
true
.
keycode
is pressed;
otherwise. On the Macintosh,
false
.
onKeyDown
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?
Questions and answers