From: Ardis Lu Date: Mon, 28 Oct 2024 04:27:31 +0000 (-0700) Subject: Enable pressing spacebar to click links X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=65265ea1f195f9a03ed3156172e784f2d0054c86;p=ardislu.dev Enable pressing spacebar to click links --- 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 = `┌──────────────────────────────────────────────────────────┐