Groups | Blog | Home
all groups > flash (macromedia) > october 2007 >

flash (macromedia) : Keyboard numbers



chrisf671
10/19/2007 10:25:14 PM
Can someone tell me the number for the space bar for action script 2 if you want to tell it to do something when you click the space bar.

dzedward
10/19/2007 10:41:14 PM
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if(Key.getCode() == "32"){
// do something
}
};
Key.addListener(keyListener);


**You will need to disable keyboard shortcuts to test this within the IDE**


David Stiller
10/21/2007 8:32:53 PM
chrisf671,

In case you're interested in other key codes as well, search the phrase
"Keyboard Keys and Key Code Values" in the Help docs and you'll find the
whole list. If you have Flash CS3 and are using ActionScript 3.0, you'll
see that even in the Help doc book "Programming ActionScript 3.0," >
"Capturing user input" > "Capturing keyboard input," a link still directs
you to the list for ActionScript 2.0. So they haven't changed.


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."

AddThis Social Bookmark Button