Add customizable keyboard shortcuts

Drive app shortcuts from a central keybindings store (defaults +
localStorage overrides). In the Info panel's Shortcuts tab: click a
shortcut to rebind, right-click to reset, Esc to cancel; combos
already in use are rejected.
This commit is contained in:
mf
2026-06-21 10:37:58 +03:30
parent db2bef892a
commit 62d5388176
4 changed files with 376 additions and 99 deletions
+4 -5
View File
@@ -12,6 +12,7 @@
theme
} from '$lib/stores/app';
import { readNote } from '$lib/api';
import { keybindings, matchAction } from '$lib/keybindings';
import type { FileEvent } from '$lib/types';
let { notePath }: { notePath: string } = $props();
@@ -73,13 +74,11 @@
}
function handleKeydown(e: KeyboardEvent) {
const mod = e.ctrlKey || e.metaKey;
if (mod && !e.shiftKey && e.code === 'KeyS') {
const action = matchAction(e, $keybindings);
if (action === 'save') {
e.preventDefault();
editor?.forceSave();
return;
}
if (mod && e.shiftKey && e.code === 'KeyM') {
} else if (action === 'toggle-source') {
e.preventDefault();
$sourceMode = !$sourceMode;
}