From: Christian Heller Date: Sun, 13 Dec 2020 01:51:22 +0000 (+0100) Subject: In web client, enable keyboard control except if in outer HTML input field. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/do_todos?a=commitdiff_plain;h=baab6e8ac2ff4215e6d57765c992b67134572dce;p=plomrogue2 In web client, enable keyboard control except if in outer HTML input field. --- diff --git a/rogue_chat.html b/rogue_chat.html index 0ba8cf0..0738740 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -16,9 +16,6 @@ terminal rows:

 
-
-keyboard input/control: -

button controls for hard-to-remember keybindings

@@ -1512,7 +1509,9 @@ tui.inputEl.addEventListener('input', (event) => { tui.full_refresh(); }, false); document.onclick = function() { - tui.show_help = false; + if (!tui.mode.is_single_char_entry) { + tui.show_help = false; + } }; tui.inputEl.addEventListener('keydown', (event) => { tui.show_help = false; @@ -1715,18 +1714,9 @@ window.setInterval(function() { } }, 1000); window.setInterval(function() { - let val = "?"; - let span_decoration = "none"; - if (document.activeElement == tui.inputEl) { - val = "on (click outside terminal to change)"; - } else { - val = "off (click into terminal to change)"; - span_decoration = "line-through"; + if (document.activeElement.tagName.toLowerCase() != 'input') { + tui.inputEl.focus(); }; - document.getElementById("keyboard_control").textContent = val; - for (const span of document.querySelectorAll('.keyboard_controlled')) { - span.style.textDecoration = span_decoration; - } }, 100); document.getElementById("terminal").onclick = function() { tui.inputEl.focus(); @@ -1775,14 +1765,20 @@ for (const move_button of document.querySelectorAll('[id*="_move_"]')) { continue; }; let direction = move_button.id.split('_')[2].toUpperCase(); - move_button.onclick = function() { - if (tui.mode.available_actions.includes("move")) { - server.send(['TASK:MOVE', direction]); - } else if (tui.mode.available_actions.includes("move_explorer")) { - explorer.move(direction); - tui.full_refresh(); - }; + let move_repeat; + move_button.onmousedown = function() { + move_repeat = window.setInterval(function() { + if (tui.mode.available_actions.includes("move")) { + server.send(['TASK:MOVE', direction]); + } else if (tui.mode.available_actions.includes("move_explorer")) { + explorer.move(direction); + tui.full_refresh(); + }; + }, 100); }; + move_button.onmouseup = function() { + window.clearInterval(move_repeat); + } };