
Key.isToggled() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
562
|
ActionScript Language Reference
of the right arrow key is ignored if the left arrow key is depressed. Regardless, the state of
the up arrow key is always checked in a separate if statement. A working version of this
spaceship example is available at the online Code Depot:
// Code for a spaceship clip
spaceship_mc.onEnterFrame = function () {
if (Key.isDown(Key.LEFT)) { // Left arrow
this._rotation -= 10;
} else if (Key.isDown(Key.RIGHT)) { // Right arrow
this._rotation += 10;
}
if (Key.isDown(Key.UP)) { // Up arrow
this.thrust += 10;
}
}
See Also
Button keyPress, Key.getAscii( ), Key.getCode( ), Key.isToggled( ); Appendix B
Key.isToggled() Method
check whether the Caps Lock, Num Lock, or Scroll Lock keys are activated
Flash 5
Key.isToggled(keycode)
Arguments
keycode An integer keycode, usually the keycode of the Caps Lock key (20), Num
Lock key (144), or Scroll Lock key (145). Can also be the key constant
Key.
CAPSLOCK
.
Returns
A Boolean indicating whether the key specified by keycode is locked on (true) or off
(
false).
Description
The isToggled( ) method detects the state of the special Caps Lock, Num Lock, or Scroll
Lock keys. Unlike other keys, these keys have a locked “on” state and an unlocked “off”
state, indicating whether or not the feature they represent