diff --git a/src/js/ui.js b/src/js/ui.js index 0319747..fe808b3 100644 --- a/src/js/ui.js +++ b/src/js/ui.js @@ -82,10 +82,18 @@ export default function initPage() { handleOpenPopup: function (e) { e.preventDefault(); this.$tg.style.display = "block"; + this.$tg.setAttribute("tabindex", "-1"); + this.$tg.focus({ preventScroll: true }); + this.$tg.addEventListener("keydown", this.handleEsc.bind(this)); }, handleClosePopup: function (e) { e.preventDefault(); this.$tg.style.display = "none"; + this.$tg.removeEventListener("keydown", this.handleEsc.bind(this)); + }, + handleEsc: function (e) { + if (e.key === "Escape") + this.handleClosePopup(e); }, }; document.querySelector(".lnk_go_template") && template.init();