diff --git a/main.js b/main.js index d5b70a61..e19c4143 100644 --- a/main.js +++ b/main.js @@ -374,20 +374,33 @@ main.dom.body.onkeydown = function(e) { ////// 在界面上放开某按键时 ////// main.dom.body.onkeyup = function(e) { - if (core.dom.startPanel.style.display == 'block' && - (main.dom.startButtons.style.display == 'block' || main.dom.levelChooseButtons.style.display == 'block')) { - if (e.keyCode == 38 || e.keyCode == 33) // up/pgup - main.selectButton((main.selectedButton||0) - 1); - else if (e.keyCode == 40 || e.keyCode == 34) // down/pgdn - main.selectButton((main.selectedButton||0) + 1); - else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32) // C/Enter/Space - main.selectButton(main.selectedButton); - return; - } - try { - if (main.dom.inputDiv.style.display == 'block') return; - if (main.core && (main.core.isPlaying() || main.core.status.lockControl)) + if (main.dom.startPanel.style.display == 'block' && + (main.dom.startButtons.style.display == 'block' || main.dom.levelChooseButtons.style.display == 'block')) { + if (e.keyCode == 38 || e.keyCode == 33) // up/pgup + main.selectButton((main.selectedButton||0) - 1); + else if (e.keyCode == 40 || e.keyCode == 34) // down/pgdn + main.selectButton((main.selectedButton||0) + 1); + else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32) // C/Enter/Space + main.selectButton(main.selectedButton); + e.stopPropagation(); + return; + } + if (main.dom.inputDiv.style.display == 'block') { + if (e.keyCode == 13) { + setTimeout(function () { + main.dom.inputYes.click(); + }, 50); + } + else if (e.keyCode == 27) { + setTimeout(function () { + main.dom.inputNo.click(); + }, 50); + } + return; + } + if (main.core && main.core.isPlaying && main.core.status && + (main.core.isPlaying() || main.core.status.lockControl)) main.core.onkeyUp(e); } catch (ee) { main.log(ee); } } @@ -732,19 +745,6 @@ main.dom.inputNo.onclick = function () { if (func) func(null); } -main.dom.inputDiv.onkeyup = function (e) { - if (e.keyCode == 13) { - setTimeout(function () { - main.dom.inputYes.click(); - }, 50); - } - else if (e.keyCode == 27) { - setTimeout(function () { - main.dom.inputNo.click(); - }, 50); - } -} - }//listen end var main = new main(); \ No newline at end of file