【AS3代码】Keyboard键盘操作!

package
{
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    import flash.events.Event;
    
    public class Main extends Sprite
    {    
        private var flag:Boolean = new Boolean();
        public function Main():void
        {
            stage.addEventListener(KeyboardEvent.KEY_DOWN, a);
            stage.addEventListener(KeyboardEvent.KEY_UP,b);
        }
        private function a(evt:KeyboardEvent):void
        {
            trace("点击键盘的KEY数字代码: "+evt.keyCode);
        }
        private function b(evt:KeyboardEvent):void
        {
            trace("弹起键盘的KEY数字代码: "+evt.keyCode);
        }
    }
    
    
}
posted @ 2012-04-16 11:32  王翔(kingfly)  阅读(2003)  评论(0编辑  收藏  举报