User Guide

362 Chapter 2: ActionScript Language Reference
Key.onKeyUp
Availability
Flash Player 6.
Usage
keyListener.onKeyUp
Description
Listener; notified when a key is released. To use onKeyUp, you must create a listener object. You
can then define a function for
onKeyUp and use addListener() to register the listener with the
Key object, as shown in the following example:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("DOWN -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey:
"+chr(Key.getAscii()));
};
keyListener.onKeyUp = function() {
trace("UP -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey:
"+chr(Key.getAscii()));
};
Key.addListener(keyListener);
Listeners enable different pieces of code to cooperate because multiple listeners can receive
notification about a single event.
See also
Key.addListener()