diff --git a/src/web_ui/index.html b/src/web_ui/index.html index 661552b..ef6c32b 100644 --- a/src/web_ui/index.html +++ b/src/web_ui/index.html @@ -134,6 +134,7 @@ + @@ -1445,6 +1446,52 @@ function schedulePoll(ms){ } schedulePoll(600); +/* ── Keyboard shortcuts ─────────────────────────────────────────── */ +// Listed in the ? help dialog below. Skip when the user is typing in a +// text input — otherwise pressing `r` while typing a filename would +// trigger a rescan. +document.addEventListener('keydown',(e)=>{ + const tag=(document.activeElement?.tagName||'').toLowerCase(); + const inField=tag==='input'||tag==='textarea'||document.activeElement?.isContentEditable; + // Esc always closes the topmost modal — even from within an input. + if(e.key==='Escape'){ + const modals=document.querySelectorAll('.modal-bg'); + if(modals.length){modals[modals.length-1].remove();e.preventDefault();return} + } + if(inField)return; + switch(e.key){ + case '/': + document.getElementById('search')?.focus(); + e.preventDefault(); + break; + case 'r': + rescan(); + e.preventDefault(); + break; + case '?': + showShortcutsHelp(); + e.preventDefault(); + break; + } +}); +function showShortcutsHelp(){ + if(document.getElementById('shortcuts-help'))return; + const bg=document.createElement('div');bg.className='modal-bg';bg.id='shortcuts-help'; + bg.onclick=e=>{if(e.target===bg)bg.remove()}; + const row=(k,d)=>`