From: Ardis Lu Date: Wed, 2 Apr 2025 04:36:38 +0000 (-0700) Subject: Focus input on "/" key press X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=93a645371142dfc3cce6b2eb969441f5df0bf1f7;p=utf-8-visualizer Focus input on "/" key press --- diff --git a/script.js b/script.js index 53b6318..d8a88db 100644 --- a/script.js +++ b/script.js @@ -98,3 +98,7 @@ const input = document.querySelector('input'); input.addEventListener('input', e => handleChange(e.target.value)); input.value = new URL(document.location).searchParams.get('q') ?? '🏴‍☠️'; handleChange(input.value); // Render the default value on first load + +addEventListener('keyup', e => { + if (e.key === '/') { input.focus(); } +});