Key
373
Example
The following example creates a new listener object and defines a function for
onKeyDown
and
onKeyUp
. The last line uses
addListener()
to register the listener with the Key object so that
it can receive notification from the key down and key up events.
var myListener:Object = new Object();
myListener.onKeyDown = function () {
trace ("You pressed a key.");
}
myListener.onKeyUp = function () {
trace ("You released a key.");
}
Key.addListener(myListener);
See also
getCode (Key.getCode method)
,
isDown (Key.isDown method)
,
onKeyDown
(Key.onKeyDown event listener)
,
onKeyUp (Key.onKeyUp event listener)
,
removeListener (Key.removeListener method)
BACKSPACE (Key.BACKSPACE property)
public static BACKSPACE :
Number
The key code value for the Backspace key (8).
Availability:
ActionScript 1.0; Flash Lite 2.0
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.BACKSPACE)) {
trace("you pressed the Backspace key.");
} else {
trace("you DIDN'T press the Backspace key.");
}
};
Key.addListener(keyListener);
When using this example, make sure that you select Control > Disable Keyboard Shortcuts in
the test environment.
Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...