From 7ef70c5adfd5f1b4a4736199c78ee8209b10805b Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 15 Nov 2020 23:57:04 +0100
Subject: [PATCH] Web client: Don't constantly force focus on terminal input.

---
 rogue_chat_nocanvas_monochrome.html | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/rogue_chat_nocanvas_monochrome.html b/rogue_chat_nocanvas_monochrome.html
index 6093f95..0890647 100644
--- a/rogue_chat_nocanvas_monochrome.html
+++ b/rogue_chat_nocanvas_monochrome.html
@@ -379,6 +379,7 @@ let tui = {
     };
   },
   switch_mode: function(mode) {
+    this.inputEl.focus();
     this.show_help = false;
     this.map_mode = 'terrain';
     if (mode.shows_info && game.player_id in game.things) {
@@ -861,7 +862,6 @@ tui.inputEl.addEventListener('input', (event) => {
     }
     tui.full_refresh();
 }, false);
-
 tui.inputEl.addEventListener('keydown', (event) => {
     tui.show_help = false;
     if (event.key == 'Enter') {
@@ -989,12 +989,6 @@ for (let key_selector of key_selectors) {
         tui.init_keys();
     }, false);
 }
-window.setInterval(function() {
-    if (!(['input', 'n_cols', 'n_rows'].includes(document.activeElement.id)
-          || document.activeElement.id.startsWith('key_'))) {
-        tui.inputEl.focus();
-    }
-}, 100);
 window.setInterval(function() {
     if (server.connected) {
         server.send(['PING']);
@@ -1003,7 +997,9 @@ window.setInterval(function() {
         tui.log_msg('@ attempting reconnect …')
     }
 }, 5000);
-
+document.getElementById("terminal").onclick = function() {
+    tui.inputEl.focus();
+};
 document.getElementById("help").onclick = function() {
     tui.show_help = true;
     tui.full_refresh();
-- 
2.30.2