Actionscript 3 AS3中的多个按键条件

Actionscript 3 AS3中的多个按键条件,actionscript-3,keypress,Actionscript 3,Keypress,我正在创建一个需要同时按下按键作为确认的游戏 目前,我正在尝试在if语句中使用带有&&条件的charCode: function reportKeyDown(event:KeyboardEvent):void { if (event.charCode == 97 && 109 && 13) { gotoAndStop(30) } else { gotoAndStop(20) //sub

我正在创建一个需要同时按下按键作为确认的游戏

目前,我正在尝试在if语句中使用带有&&条件的charCode:

function reportKeyDown(event:KeyboardEvent):void 
{ 
    if (event.charCode == 97 && 109 && 13)
    {
     gotoAndStop(30) 
    }
    else {
        gotoAndStop(20)
        //subtract 5hp
    }
} 
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);

到目前为止,它只能识别第一个键。有没有办法解决这个问题

一种可能的解决方案是将键码保存在数组中,并检查短时间后按下的键

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
var timer:Timer=new Timer(100);
var tmpKeys:Array=[];
timer.addEventListener(TimerEvent.TIMER,reportKeyDown);
function keyDownHandler(e:KeyboardEvent):void{ 
    trace(e.keyCode);
    tmpKeys.push(e.keyCode);
    timer.start();
} 
function reportKeyDown(e:TimerEvent):void{
    if(keysAreDown([Keyboard.N,Keyboard.P])) //check for simultaneous pressing of 'n' and 'p'
        trace("yesss!");
    else
        trace("nooo!");
    tmpKeys=[];
    timer.stop();
}
function keysAreDown(keys:Array):Boolean{
    for each(var key:int in keys)
        if(tmpKeys.indexOf(key)==-1)
            return false;
    return true;
}