Key.addListener()
409
Listener summary for the Key class
Key.addListener()
Availability
Flash Player 6.
Usage
Key.addListener (
newListener
)
Parameters
newListener
An object with methods
onKeyDown
and
onKeyUp
.
Returns
Nothing.
Description
Method; registers an object to receive
onKeyDown
and
onKeyUp
notification. When a key is
pressed or released, regardless of the input focus, all listening objects registered with
addListener()
have either their
onKeyDown
method or
onKeyUp
method invoked. Multiple
objects can listen for keyboard notifications. If the listener
newListener
is already registered, no
change occurs.
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.
myListener = new Object();
myListener.onKeyDown = function () {
trace ("You pressed a key.");
}
myListener.onKeyUp = function () {
trace ("You released a key.");
}
Key.addListener(myListener);
Key.RIGHT
Constant associated with the key code value for the Right Arrow key (39).
Key.SHIFT
Constant associated with the key code value for the Shift key (16).
Key.SPACE
Constant associated with the key code value for the Spacebar (32).
Key.TAB
Constant associated with the key code value for the Tab key (9).
Key.UP
Constant associated with the key code value for the Up Arrow key (38).
Method
Description
Key.onKeyDown
Notified when a key is pressed.
Key.onKeyUp
Notified when a key is released.
Property
Description
Содержание FLASH MX 2004 - ACTIONSCRIPT
Страница 1: ...ActionScript Reference Guide...
Страница 8: ...8 Contents...
Страница 12: ......
Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Страница 54: ...54 Chapter 2 ActionScript Basics...
Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...
Страница 82: ......
Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Страница 112: ......
Страница 120: ...120 Chapter 6 Using the Built In Classes...
Страница 176: ......
Страница 192: ...192 Chapter 10 Working with External Data...
Страница 202: ...202 Chapter 11 Working with External Media...
Страница 204: ......
Страница 782: ...782 Chapter 12 ActionScript Dictionary...
Страница 793: ...Other keys 793 221 222 Key Key code...
Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Страница 816: ...816 Index...