Fix Ctrl+A: use e.key instead of e.code, move before generic Ctrl guard

Ctrl+A was selecting page text instead of entries. Switched from e.code === 'KeyA' (layout-dependent) to e.key === 'a'. Moved handler before the generic Ctrl+key else-if chain and before the combined preventDefault block, with its own e.preventDefault() and early return. Handles both 'a' and 'A' key values.
This commit is contained in:
2026-05-09 19:13:58 +01:00
parent e414b4f600
commit 37c15ecad6
+10 -8
View File
@@ -1422,10 +1422,19 @@ document.addEventListener('keydown', function(e) {
// Prevent browser defaults for ALL our shortcuts BEFORE dispatching // Prevent browser defaults for ALL our shortcuts BEFORE dispatching
const code = e.code; const code = e.code;
if (code === 'KeyN' || code === 'KeyF' || code === 'KeyT' || code === 'KeyL' || code === 'KeyS' || code === 'KeyA') { if (code === 'KeyN' || code === 'KeyF' || code === 'KeyT' || code === 'KeyL' || code === 'KeyS') {
e.preventDefault(); e.preventDefault();
} }
if (e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && (e.key === 'a' || e.key === 'A') && !isInput && document.getElementById('authSection').classList.contains('hidden')) {
e.preventDefault();
getFilteredEntries(view === 'grouped' || view === 'detail').forEach(e => selectedIds.add(e.id));
updateBatchBar();
render();
playSound('click');
return;
}
if (code === 'KeyN') { if (code === 'KeyN') {
if (!isInput && !document.getElementById('addModal').classList.contains('show')) openAdd(); if (!isInput && !document.getElementById('addModal').classList.contains('show')) openAdd();
} else if (code === 'KeyF') { } else if (code === 'KeyF') {
@@ -1438,12 +1447,5 @@ document.addEventListener('keydown', function(e) {
} else if (code === 'KeyS') { } else if (code === 'KeyS') {
if (document.getElementById('addModal').classList.contains('show')) addEntry(); if (document.getElementById('addModal').classList.contains('show')) addEntry();
else if (document.getElementById('editModal').classList.contains('show')) saveEdit(); else if (document.getElementById('editModal').classList.contains('show')) saveEdit();
} else if (code === 'KeyA') {
if (!isInput && document.getElementById('authSection').classList.contains('hidden')) {
getFilteredEntries(view === 'grouped' || view === 'detail').forEach(e => selectedIds.add(e.id));
updateBatchBar();
render();
playSound('click');
}
} }
}); });