page 13 KeyBoardEvent

//按键盘返回键控代码
package
{
	import flash.display.Sprite;
	import flash.events.KeyboardEvent;
	
	public class Main extends Sprite
	{
		
		public function Main()
		{
			stage.focus = this;
			addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
		}
		
		private function onKeyDown(event:KeyboardEvent):void
		{
			trace("key down: " + event.charCode);
		}
	}
}


你可能感兴趣的:(【读书笔记】AS3,CookBook,function,import,class)