键盘组合键
//保存按键的对象(联合数组) var key_obj:Object = new Object ; function onKeyDownHandler(_evt:KeyboardEvent):void { //记录当前被按下的键,用键控码也行 key_obj[String.fromCharCode(_evt.keyCode)] = true; } function onKeyUpHandler(_evt:KeyboardEvent):void { //键弹起,从对象中删除当前键 key_obj[String.fromCharCode(_evt.keyCode)] = null; } stage.addEventListener("keyUp",onKeyUpHandler); stage.addEventListener("keyDown",onKeyDownHandler); function moveCir(_evt:Event):void { var _sprite:Sprite = _evt.target as Sprite; //根据对象中记录的键被按下的情况,运行 if (key_obj["K"]) { trace("K发子弹"); } if (key_obj["S"]) { trace("S被按下"); } } addEventListener("enterFrame",moveCir);