From f71b025db67f325d9a9b27ba551ae17b0cf81620 Mon Sep 17 00:00:00 2001 From: MoPaMo Date: Wed, 16 Jun 2021 07:15:03 +0200 Subject: [PATCH] close text modal on escape press --- client/scripts/ui.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/scripts/ui.js b/client/scripts/ui.js index 93dd77e..3e2af9c 100644 --- a/client/scripts/ui.js +++ b/client/scripts/ui.js @@ -215,9 +215,13 @@ class Dialog { this.$el.querySelectorAll("[close]").forEach((el) => { el.addEventListener("click", (e) => this.hide()); }); - this.$el.querySelectorAll("[role=\"textbox\"]").forEach((el) => { - el.addEventListener("click", (e) => this.hide()); + this.$el.querySelectorAll('[role="textbox"]').forEach((el) => { + el.addEventListener("keypress", (e) => { + if (e.key == "Escape") { + this.hide(); + } }); + }); this.$autoFocus = this.$el.querySelector("[autofocus]"); }