From 3b2173c694e9d9bacfbf70c5fbed239fdb5de1de Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 10 Jun 2018 13:46:00 +0300 Subject: [PATCH] Focus into input if trying to type into any non-input element Fixes #2473 --- client/js/keybinds.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/js/keybinds.js b/client/js/keybinds.js index 4b40e9c1..bb27af31 100644 --- a/client/js/keybinds.js +++ b/client/js/keybinds.js @@ -247,11 +247,10 @@ const ignoredKeys = { 224: true, // Meta }; -$(document.body).on("keydown", (e) => { - // Ignore if target isn't body (e.g. focused into input) +$(document).on("keydown", (e) => { // Ignore any key that uses alt modifier // Ignore keys defined above - if (e.target !== document.body || e.altKey || ignoredKeys[e.which]) { + if (e.altKey || ignoredKeys[e.which]) { return; } @@ -260,6 +259,13 @@ $(document.body).on("keydown", (e) => { return; } + const tagName = e.target.tagName; + + // Ignore if we're already typing into or