Merge pull request #1319 from Cube14yt/mobile_keybinds
mobile_keybinds.js bugfix
This commit is contained in:
commit
8637d81896
|
|
@ -1,16 +1,24 @@
|
||||||
(() => {
|
(() => {
|
||||||
function runKeybind() {
|
function runKeybind() {
|
||||||
promptInput("Input the keybind you want to run. (e.g. KeyA, Digit1, Backspace)", (keybind) => {
|
promptInput("Input the keybind you want to run. (e.g. KeyA, Digit1, Backspace)", (keybind) => {
|
||||||
|
if (/^[A-Za-z]$/.test(keybind)) keybind = "Key" + keybind.toUpperCase()
|
||||||
|
if (/^[0-9]$/.test(keybind)) {
|
||||||
|
setView(Number(keybind))
|
||||||
|
}
|
||||||
if (keybinds[keybind]) {
|
if (keybinds[keybind]) {
|
||||||
keybinds[keybind]();
|
keybinds[keybind]();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile) {
|
function loadButton() {
|
||||||
const keybindButton = document.createElement("button")
|
const keybindButton = document.createElement("button")
|
||||||
|
if (!keybindButton) {
|
||||||
|
setTimeout(loadButton, 100)
|
||||||
|
return
|
||||||
|
}
|
||||||
keybindButton.id = "keybindButton"
|
keybindButton.id = "keybindButton"
|
||||||
keybindButton.title = "Change static mode"
|
keybindButton.title = "Input a keybind"
|
||||||
keybindButton.classList.add("controlButton")
|
keybindButton.classList.add("controlButton")
|
||||||
keybindButton.onclick = () => {
|
keybindButton.onclick = () => {
|
||||||
runKeybind()
|
runKeybind()
|
||||||
|
|
@ -18,4 +26,8 @@
|
||||||
keybindButton.textContent = "Keybind"
|
keybindButton.textContent = "Keybind"
|
||||||
document.getElementById("pauseButton").before(keybindButton)
|
document.getElementById("pauseButton").before(keybindButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isMobile) {
|
||||||
|
loadButton()
|
||||||
|
}
|
||||||
})()
|
})()
|
||||||
Loading…
Reference in New Issue