Return to Snippet

Revision: 23656
at February 10, 2010 15:39 by adrianparr


Initial Code
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");
	} 
}

Initial URL


Initial Description
Use this to detect key presses and respond to them.

Initial Title
AS3 Detecting key presses

Initial Tags
user

Initial Language
ActionScript 3