Add keyboard shortcuts for sidebar, theme, focus mode, read-only, and fullscreen toggles

This commit is contained in:
Yuri Karamian
2026-03-17 22:37:48 +01:00
parent 9f595212dd
commit e87a2edc00
3 changed files with 50 additions and 8 deletions
+26 -1
View File
@@ -41,7 +41,7 @@
const appWindow = getCurrentWindow();
const isMac = navigator.platform.startsWith('Mac');
const isMobile = /android|ios/i.test(navigator.userAgent);
import { loadVaultState, saveVaultState, readNote, createDailyNote, createBackup, getPendingOpenFile, addQuickAccess, removeQuickAccess, getQuickAccess } from '$lib/api';
import { loadVaultState, saveVaultState, readNote, createDailyNote, createBackup, getPendingOpenFile, addQuickAccess, removeQuickAccess, getQuickAccess, setTheme } from '$lib/api';
import { debounce } from '$lib/utils/debounce';
import { openNoteWindow } from '$lib/utils/window';
import { get } from 'svelte/store';
@@ -268,6 +268,11 @@
}
if (mod && e.shiftKey && e.key === 'N') {
e.preventDefault();
const isDark = $theme === 'dark' || ($theme === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches);
const next = isDark ? 'light' : 'dark';
$theme = next;
setTheme(next);
return;
}
if (mod && e.shiftKey && e.key === 'F') {
e.preventDefault();
@@ -305,6 +310,26 @@
openNoteWindow($activeNotePath, $activeNote.meta.title);
}
}
if (mod && e.key === '\\') {
e.preventDefault();
$sidebarCollapsed = !$sidebarCollapsed;
return;
}
if (mod && e.shiftKey && e.key === 'E') {
e.preventDefault();
$focusMode = !$focusMode;
return;
}
if (mod && e.shiftKey && e.key === 'R') {
e.preventDefault();
$readOnly = !$readOnly;
return;
}
if (e.key === 'F11') {
e.preventDefault();
appWindow.isFullscreen().then(fs => appWindow.setFullscreen(!fs));
return;
}
if (e.key === 'Escape') {
if ($showSettings) $showSettings = false;
else if ($showInfo) $showInfo = false;