/ Published in: ActionScript 3
                    
                                        
Use this to detect key presses and respond to them.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onStage_KEY_DOWN);
stage.addEventListener(KeyboardEvent.KEY_UP, onStage_KEY_UP);
function onStage_KEY_DOWN(event:KeyboardEvent):void
{
trace("onStage_KEY_DOWN");
if (event.keyCode == Keyboard.SPACE) {
trace("Keyboard.SPACE");
}
}
function onStage_KEY_UP(event:KeyboardEvent):void
{
trace("onStage_KEY_UP");
if (event.keyCode == Keyboard.SPACE) {
trace("Keyboard.SPACE");
}
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                