finally fix shortcuts triggering on prompt fields

Basically checks if focus is an input field, and transfer focus to
window as soon as mouse hovers over the canvas

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>

Former-commit-id: 5ce4877c69708a1ea981d9dac4b9102048152e58
This commit is contained in:
Victor Seiji Hariki 2022-11-23 08:24:18 -03:00
parent 5b2a6234d4
commit f5b0369476
2 changed files with 14 additions and 2 deletions

View file

@ -243,7 +243,10 @@ people, person, humans, human, divers, diver, glitch, error, text, watermark, ba
</div>
<!-- Canvases -->
<div id="mainHSplit" class="mainHSplit">
<div
id="mainHSplit"
class="mainHSplit"
onmouseover="document.activeElement.blur()">
<div id="uiWrapper" class="uiWrapper">
<div
id="canvasHolder"

View file

@ -363,7 +363,16 @@ window.onkeydown = (evn) => {
};
// Process shortcuts if input target is not a text field
if (evn.target instanceof HTMLInputElement && evn.type === "text") return;
switch (evn.target.tagName.toLowerCase()) {
case "input":
case "textarea":
case "select":
case "button":
return; // If in an input field, do not process shortcuts
default:
// Do nothing
break;
}
const callbacks = keyboard.shortcuts[evn.code];