From ad37e9abe7bb2553485043c7dc6be594d09e9d6c Mon Sep 17 00:00:00 2001 From: Jeremy Plsek Date: Wed, 15 Jan 2020 20:50:51 -0500 Subject: [PATCH] Allow keybind cancel with ESC --- options/options.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/options/options.js b/options/options.js index d2f3b440..bc173d25 100644 --- a/options/options.js +++ b/options/options.js @@ -234,6 +234,15 @@ function keybindKeyPressed(element, e) { e = e || window.event; var key = e.key; + let button = element.querySelector(".trigger-button"); + + // cancel setting a keybind + if (key === "Escape") { + element.querySelector(".option-hidden-section").classList.add("hidden"); + button.classList.remove("disabled"); + return; + } + let option = element.getAttribute("sync-option"); SB.config[option] = key; @@ -244,8 +253,6 @@ function keybindKeyPressed(element, e) { let statusKey = element.querySelector(".option-hidden-section > .keybind-status-key"); statusKey.innerText = key; - let button = element.querySelector(".trigger-button"); - button.classList.remove("disabled"); }