Example
The following example calls the
creates a listener object named
event by calling
onKeyDown
object, which broadcasts the
Key
file plays.
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("The ASCII code for the last key typed is: "+Key.getAscii());
};
Key.addListener(keyListener);
The following example adds a call to
main difference is that
and
Key.getCode()
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("For the last key typed:");
trace("\tThe Key code is: "+Key.getCode());
trace("\tThe ASCII value is: "+Key.getAscii());
trace("");
};
Key.addListener(keyListener);
Key.getCode()
Availability
Flash Player 5.
Usage
Key.getCode() : Number
Parameters
None.
Returns
A number; an integer that represents the key code of the last key pressed.
Description
Method; returns the key code value of the last key pressed. To match the returned key code value
with the key on a standard keyboard, see
page
811.
getAscii()
keyListener
Key.getAscii()
onKeyDown
Key.getAscii()
differentiates between uppercase and lowercase letters,
Key.getAscii()
does not.
Appendix B, "Keyboard Keys and Key Code Values," on
method any time a key is pressed. The example
and defines a function that responds to the
. The
object is then registered to the
keyListener
message whenever a key is pressed while the SWF
to show how the two methods differ. The
Key.getCode()
303
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?