From 65265ea1f195f9a03ed3156172e784f2d0054c86 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sun, 27 Oct 2024 21:27:31 -0700 Subject: [PATCH] Enable pressing spacebar to click links --- script.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/script.js b/script.js index 6cda474..9a51f6d 100644 --- a/script.js +++ b/script.js @@ -394,6 +394,14 @@ document.addEventListener('click', e => { } }); +/* Enable pressing spacebar to click links. */ +document.addEventListener('keydown', e => { + if (e.code === 'Space' && e.target?.tagName === 'A') { + e.preventDefault(); + e.target.click(); + } +}); + /* DevTools console help message. */ const ascii = `┌──────────────────────────────────────────────────────────┐ -- 2.47.3