
Key.isDown() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
561
_root.gotoAndStop("mainInterface");
}
}
Key.addListener(keyListener);
See Also
Button keyPress, Key.getAscii( ), Key.isDown( ); Appendix B
Key.isDown() Method
check whether a specific key is currently depressed
Flash 5
Key.isDown(keycode)
Arguments
keycode A number representing the keycode of the key to check. Can also be one of
the
Key constants (e.g., Key.UP, Key.BACKSPACE).
Returns
A Boolean indicating whether the key specified by keycode is currently depressed (true)or
not (
false).
Description
The isDown( ) method tells us whether the key specified by keycode is currently being
pressed, such as:
trace(isDown(65)); // Displays: true if the "A" key is depressed during the test
It offers immediate access to the state of the keyboard and is best used with systems that
require constant key-based input or that detect the pressing of simultaneous keys.
The isDown( ) method offers three advantages over getCode( ) and getAscii( ); it can:
• Detect the state of modifier keys such as Ctrl, Command, Shift, and Option, which do
not trigger keyboard events on their own. (To determine whether the Caps Lock, Num
Lock, and Scroll Lock keys are in their locked (down) state, use isToggled( ) instead.)
• Detect the state of arbitrary keys, allowing programmers ...