var key_obj: Object = new Object; function onKeyDownHandler(_evt: KeyboardEvent): void { var _code: String = String.fromCharCode(_evt.keyCode); if (key_obj.hasOwnProperty(_code)) { } else { key_obj[_code] = true; } if (_evt.ctrlKey && _code == "S" && key_obj[_code] == true) { key_obj[_code] = false; trace("Ctrl键被按下", _code); } _evt.altKey && trace("Alt键被按下"); _evt.shiftKey && trace("Shift键被按下"); //for (var p:String in key_obj) {//用于其它字母和数字鍵 // trace("当前按下的键有:"+p); //} } function onKeyUpHandler(_evt: KeyboardEvent): void { var _code: String = String.fromCharCode(_evt.keyCode); key_obj[_code] = null; delete key_obj[_code]; } function missingStage(e) { trace("DEACTIVATE"); key_obj = new Object; } function getingStage(e) { trace("ACTIVATE"); /*stage.stageFocusRect = false; stage.focus = stage;*/ } stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUpHandler); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownHandler); stage.addEventListener(Event.DEACTIVATE, missingStage); stage.addEventListener(Event.ACTIVATE, getingStage);