pause on one key press
This commit is contained in:
parent
89d0ef98f9
commit
1e8d6fb170
10
app.js
10
app.js
@ -51,12 +51,14 @@ const KEY_NAMES = {
|
|||||||
["ArrowDown"]: "↓",
|
["ArrowDown"]: "↓",
|
||||||
[" "]: "Espace",
|
[" "]: "Espace",
|
||||||
["Escape"]: "Échap",
|
["Escape"]: "Échap",
|
||||||
|
["Enter"]: "Entrée",
|
||||||
["←"]: "ArrowLeft",
|
["←"]: "ArrowLeft",
|
||||||
["→"]: "ArrowRight",
|
["→"]: "ArrowRight",
|
||||||
["↑"]: "ArrowUp",
|
["↑"]: "ArrowUp",
|
||||||
["↓"]: "ArrowDown",
|
["↓"]: "ArrowDown",
|
||||||
["Espace"]: " ",
|
["Espace"]: " ",
|
||||||
["Échap"]: "Escape",
|
["Échap"]: "Escape",
|
||||||
|
["Entrée"]: "Enter",
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Customize Array to be use as coord */
|
/* Customize Array to be use as coord */
|
||||||
@ -568,15 +570,15 @@ let nextQueue = new NextQueue("nextTable")
|
|||||||
|
|
||||||
|
|
||||||
function pause() {
|
function pause() {
|
||||||
document.onkeydown = null
|
|
||||||
document.onkeyup = null
|
|
||||||
|
|
||||||
scheduler.clearInterval(fall)
|
scheduler.clearInterval(fall)
|
||||||
scheduler.clearTimeout(lockDown)
|
scheduler.clearTimeout(lockDown)
|
||||||
scheduler.clearTimeout(repeat)
|
scheduler.clearTimeout(repeat)
|
||||||
scheduler.clearInterval(autorepeat)
|
scheduler.clearInterval(autorepeat)
|
||||||
scheduler.clearInterval(ticktack)
|
scheduler.clearInterval(ticktack)
|
||||||
stats.pauseTime = stats.time
|
stats.pauseTime = stats.time
|
||||||
|
|
||||||
|
document.onkeydown = null
|
||||||
|
|
||||||
resumeButton.disabled = false
|
resumeButton.disabled = false
|
||||||
settings.modal.show()
|
settings.modal.show()
|
||||||
}
|
}
|
||||||
@ -671,6 +673,7 @@ const REPEATABLE_ACTIONS = [
|
|||||||
]
|
]
|
||||||
pressedKeys = new Set()
|
pressedKeys = new Set()
|
||||||
actionsQueue = []
|
actionsQueue = []
|
||||||
|
|
||||||
function onkeydown(event) {
|
function onkeydown(event) {
|
||||||
if (event.key in settings.keyBind) {
|
if (event.key in settings.keyBind) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@ -769,7 +772,6 @@ function gameOver() {
|
|||||||
matrix.drawPiece()
|
matrix.drawPiece()
|
||||||
|
|
||||||
document.onkeydown = null
|
document.onkeydown = null
|
||||||
document.onkeyup = null
|
|
||||||
onblur = null
|
onblur = null
|
||||||
scheduler.clearInterval(ticktack)
|
scheduler.clearInterval(ticktack)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user