on master help sign in
now ESC closes the search window
commit5274eaa72f066502d94024dd0fc03d2e65e2bab8 authorfriederjanmoerman <hijbrid@gmail.com> dateThu 13 Jun 2019, 10:38 (7 years ago) parent6fffa3b
1 file changed+13−1
static/scripts.js+13−1
static/scripts.js+13−1
@@ -76,7 +76,18 @@ function initToggleSearchWindow() {
7676 }
7777}
7878
79−
79+//
80+ // hotkeys
81+//
82+function initHotKeys() {
83+ document.onkeydown = function(evt) {
84+ evt = evt || window.event;
85+ // ESC to close search window
86+ if (evt.keyCode == 27) {
87+ document.body.classList.remove('has-active-search-window');
88+ }
89+ };
90+};
8091
8192//
8293 // search functionality
@@ -301,5 +312,6 @@ if (document.readyState === "complete" ||
301312 document.addEventListener("DOMContentLoaded", function () {
302313 initToggleSearchWindow();
303314 initSearch();
315+ initHotKeys();
304316 });
305317}