Actionscript 2 key listener
A simple and effective way of attaching a listener to a flash document. Great for using keyboard presses to perform actions on a website. The example below can be used to call a function when the user hits the enter key on their keyboard.
keyListener = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == Key.ENTER){
trace('you just hit the enter button')
}
};
Key.addListener(keyListener);
Tags: actionscript, flash
This entry was posted on Tuesday, February 23rd, 2010 at 1:21 pm and is filed under ActionScript & Flash. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Jamie Shepherd said: February 25, 2010 at 11:29 pm
That’s actually very useful! Thanks Mr. Bourne.