From 06fb3cf501c7e602024aad6a41703b4831ff0102 Mon Sep 17 00:00:00 2001 From: Cube14yt Date: Fri, 12 Dec 2025 16:30:40 +0800 Subject: [PATCH] Update mobile_keybinds.js --- mods/mobile_keybinds.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mods/mobile_keybinds.js b/mods/mobile_keybinds.js index 9afbeb6d..f91c8079 100644 --- a/mods/mobile_keybinds.js +++ b/mods/mobile_keybinds.js @@ -1,16 +1,24 @@ (() => { function runKeybind() { 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]) { keybinds[keybind](); } }) } - if (isMobile) { + function loadButton() { const keybindButton = document.createElement("button") + if (!keybindButton) { + setTimeout(loadButton, 100) + return + } keybindButton.id = "keybindButton" - keybindButton.title = "Change static mode" + keybindButton.title = "Input a keybind" keybindButton.classList.add("controlButton") keybindButton.onclick = () => { runKeybind() @@ -18,4 +26,8 @@ keybindButton.textContent = "Keybind" document.getElementById("pauseButton").before(keybindButton) } -})() \ No newline at end of file + + if (isMobile) { + loadButton() + } +})()