From c4963751b38e762dd40da059bfd41c5b82bc5f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 20 May 2021 23:16:16 +0200 Subject: '/' focuses search in HTML. --- static/script.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'static/script.js') diff --git a/static/script.js b/static/script.js index 7d3d2c29..a0d58c27 100644 --- a/static/script.js +++ b/static/script.js @@ -404,5 +404,14 @@ window.onload = function () { init_input_list(); + + document.addEventListener('keydown', function (event) { + if (event.key == '/') { + let searchbox = document.querySelector('.simplesearch [name=q]') + // focuses the input, and selects all the text in it + searchbox.select(); + event.preventDefault(); + } + }); } -- cgit v1.2.3