Onkeyup (Button.onkeyup Handler) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

onKeyUp (Button.onKeyUp handler)

onKeyUp = function() {}
Invoked when a button has input focus and a key is released. The
invoked with no parameters. You can use the
to determine which key was pressed.
Availability: ActionScript 1.0; Flash Player 6
Example
In the following example, a function that sends text to the Output panel is defined for the
onKeyDown handler
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;
}
Press Control+Enter to test the SWF file. Make sure you select Control > Disable Keyboard
Shortcuts in the test environment. Then press the Tab key until the button has focus (a yellow
rectangle appears around the
When you press keys, they are displayed in the Output panel.
See also
onKeyDown (Button.onKeyDown handler)
(Key.getCode method)
. Create a button called
instance) and start pressing keys on your keyboard.
my_btn
and
Key.getAscii()
on the Stage, and enter the following
my_btn
,
getAscii (Key.getAscii method)
event handler is
onKeyUp
methods
Key.getCode()
,
getCode
Button
363

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF