Button.onKeyUp
Availability
Flash Player 6.
Usage
my_btn.onKeyUp = function() : Void {
// your statements here
}
Parameters
None.
Returns
Nothing.
Description
Event handler; invoked when a button has input focus and a key is released. The
handler is invoked with no parameters. You can use the
methods to determine which key was pressed.
You must define a function that executes when the event handler is invoked.
Example
In the following example, a function that sends text to the Output panel is defined for the
handler. Create a button called
onKeyDown
ActionScript in a frame on the Timeline:
my_btn.onKeyDown = function() {
trace("onKeyDown: "+this._name+" (Key: "+getKeyPressed()+")");
};
my_btn.onKeyUp = function() {
trace("onKeyUp: "+this._name+" (Key: "+getKeyPressed()+")");
};
function getKeyPressed():String {
var theKey:String;
switch (Key.getAscii()) {
case Key.BACKSPACE :
theKey = "<BACKSPACE>";
break;
case Key.SPACE :
theKey = "<SPACE>";
break;
default :
theKey = chr(Key.getAscii());
}
return theKey;
}
146
Chapter 2: ActionScript Language Reference
Key.getAscii()
on the Stage, and enter the following
my_btn
event
onKeyUp
and
Key.getCode()
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers