Merge pull request #1319 from Cube14yt/mobile_keybinds

mobile_keybinds.js bugfix
This commit is contained in:
slweeb 2025-12-17 10:06:11 -05:00 committed by GitHub
commit 8637d81896
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 3 deletions

View File

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