Fix main.js

This commit is contained in:
oc 2019-07-06 09:18:57 +08:00
parent 6190b6e377
commit 834e987212

52
main.js
View File

@ -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();