【AS3代码】键盘的输入和输出

package
{
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    
    public class Main extends Sprite
    {    
        
        public function Main():void
        {
            init();
        }
        private function init():void
        {
            stage.addEventListener(KeyboardEvent.KEY_DOWN, aaa);
        }
        
        public function aaa(e:KeyboardEvent):void
        {
            //e.charCode显示输入的字符编码(会区分大小写)
            //forChareCode会将字符编码转义成输入的字符显示出来
            trace(String.fromCharCode(e.charCode));
        }
        
    }
}
posted @ 2012-07-02 11:37  王翔(kingfly)  阅读(714)  评论(0编辑  收藏  举报