Merge pull request #96 from gamosoft/features/shortcuts

Features/shortcuts
This commit is contained in:
Guillermo Villar 2025-12-14 15:45:21 +01:00 committed by GitHub
commit d5ea6f717f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 22 deletions

View File

@ -267,12 +267,14 @@ date: {{date}}
| `Ctrl+Alt+N` | `Cmd+Option+N` | New note | | `Ctrl+Alt+N` | `Cmd+Option+N` | New note |
| `Ctrl+Alt+F` | `Cmd+Option+F` | New folder | | `Ctrl+Alt+F` | `Cmd+Option+F` | New folder |
| `Ctrl+Z` | `Cmd+Z` | Undo | | `Ctrl+Z` | `Cmd+Z` | Undo |
| `Ctrl+Y` | `Cmd+Y` | Redo | | `Ctrl+Y` or `Ctrl+Shift+Z` | `Cmd+Y` or `Cmd+Shift+Z` | Redo |
| `Ctrl+Shift+Z` | `Cmd+Shift+Z` | Toggle Zen Mode | | `Ctrl+Alt+Z` | `Cmd+Option+Z` | Toggle Zen Mode |
| `Esc` | `Esc` | Exit Zen Mode | | `Esc` | `Esc` | Exit Zen Mode |
| `F3` | `F3` | Next search match | | `F3` | `F3` | Next search match |
| `Shift+F3` | `Shift+F3` | Previous search match | | `Shift+F3` | `Shift+F3` | Previous search match |
> **Note for Mac users:** Some Option-based shortcuts (`Cmd+Option+N/F/T`) may conflict with browser shortcuts in Chrome/Brave. Safari has better compatibility. If shortcuts don't work, try using `Ctrl` instead of `Cmd`, or use the UI buttons.
### Markdown Formatting ### Markdown Formatting
| Windows/Linux | Mac | Action | Result | | Windows/Linux | Mac | Action | Result |
@ -290,7 +292,7 @@ Full immersive distraction-free writing experience:
- **Hidden UI** - Sidebar, toolbar, and stats bar disappear - **Hidden UI** - Sidebar, toolbar, and stats bar disappear
- **Centered editor** - Comfortable width for optimal reading - **Centered editor** - Comfortable width for optimal reading
- **Larger text** - 18px font size with relaxed line spacing - **Larger text** - 18px font size with relaxed line spacing
- **Quick access** - Button in toolbar or `Ctrl+Shift+Z` shortcut - **Quick access** - Button in toolbar or `Ctrl+Alt+Z` / `Cmd+Option+Z` shortcut
- **Easy exit** - Press `Esc`, click exit button, or use shortcut again - **Easy exit** - Press `Esc`, click exit button, or use shortcut again
- **State preserved** - Returns to your previous view mode on exit - **State preserved** - Returns to your previous view mode on exit

View File

@ -428,44 +428,50 @@ function noteApp() {
if (!window.__noteapp_shortcuts_initialized) { if (!window.__noteapp_shortcuts_initialized) {
window.__noteapp_shortcuts_initialized = true; window.__noteapp_shortcuts_initialized = true;
window.addEventListener('keydown', (e) => { window.addEventListener('keydown', (e) => {
// Use e.code for all letter keys for consistency across keyboard layouts
// Ctrl/Cmd + S to save // Ctrl/Cmd + S to save
if ((e.ctrlKey || e.metaKey) && e.key === 's') { if ((e.ctrlKey || e.metaKey) && e.code === 'KeyS') {
e.preventDefault(); e.preventDefault();
this.saveNote(); this.saveNote();
} }
// Ctrl/Cmd + Alt + N for new note // Ctrl/Cmd + Alt/Option + N for new note
if ((e.ctrlKey || e.metaKey) && e.altKey && e.key === 'n') { if ((e.ctrlKey || e.metaKey) && e.altKey && e.code === 'KeyN') {
e.preventDefault(); e.preventDefault();
this.createNote(); this.createNote();
} }
// Ctrl/Cmd + Alt + F for new folder // Ctrl/Cmd + Alt/Option + F for new folder
if ((e.ctrlKey || e.metaKey) && e.altKey && e.key === 'f') { if ((e.ctrlKey || e.metaKey) && e.altKey && e.code === 'KeyF') {
e.preventDefault(); e.preventDefault();
this.createFolder(); this.createFolder();
} }
// Ctrl/Cmd + Z for undo // Ctrl/Cmd + Z for undo (without shift or alt)
if ((e.ctrlKey || e.metaKey) && !e.shiftKey && e.key === 'z') { if ((e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey && e.code === 'KeyZ') {
e.preventDefault(); e.preventDefault();
this.undo(); this.undo();
} }
// Ctrl/Cmd + Y for redo (Ctrl+Shift+Z now opens Zen mode) // Ctrl/Cmd + Y OR Ctrl/Cmd+Shift+Z for redo
if ((e.ctrlKey || e.metaKey) && e.key === 'y') { if ((e.ctrlKey || e.metaKey) && e.code === 'KeyY') {
e.preventDefault();
this.redo();
}
if ((e.ctrlKey || e.metaKey) && e.shiftKey && !e.altKey && e.code === 'KeyZ') {
e.preventDefault(); e.preventDefault();
this.redo(); this.redo();
} }
// F3 for next search match // F3 for next search match
if (e.key === 'F3' && !e.shiftKey) { if (e.code === 'F3' && !e.shiftKey) {
e.preventDefault(); e.preventDefault();
this.nextMatch(); this.nextMatch();
} }
// Shift + F3 for previous search match // Shift + F3 for previous search match
if (e.key === 'F3' && e.shiftKey) { if (e.code === 'F3' && e.shiftKey) {
e.preventDefault(); e.preventDefault();
this.previousMatch(); this.previousMatch();
} }
@ -474,31 +480,31 @@ function noteApp() {
const isEditorFocused = document.activeElement?.id === 'note-editor'; const isEditorFocused = document.activeElement?.id === 'note-editor';
if (isEditorFocused && this.currentNote) { if (isEditorFocused && this.currentNote) {
// Ctrl/Cmd + B for bold // Ctrl/Cmd + B for bold
if ((e.ctrlKey || e.metaKey) && e.key === 'b') { if ((e.ctrlKey || e.metaKey) && e.code === 'KeyB') {
e.preventDefault(); e.preventDefault();
this.wrapSelection('**', '**', 'bold text'); this.wrapSelection('**', '**', 'bold text');
} }
// Ctrl/Cmd + I for italic // Ctrl/Cmd + I for italic
if ((e.ctrlKey || e.metaKey) && e.key === 'i') { if ((e.ctrlKey || e.metaKey) && e.code === 'KeyI') {
e.preventDefault(); e.preventDefault();
this.wrapSelection('*', '*', 'italic text'); this.wrapSelection('*', '*', 'italic text');
} }
// Ctrl/Cmd + K for link // Ctrl/Cmd + K for link
if ((e.ctrlKey || e.metaKey) && e.key === 'k') { if ((e.ctrlKey || e.metaKey) && e.code === 'KeyK') {
e.preventDefault(); e.preventDefault();
this.insertLink(); this.insertLink();
} }
// Ctrl/Cmd + Alt + T for table // Ctrl/Cmd + Alt/Option + T for table
if ((e.ctrlKey || e.metaKey) && e.altKey && e.key === 't') { if ((e.ctrlKey || e.metaKey) && e.altKey && e.code === 'KeyT') {
e.preventDefault(); e.preventDefault();
this.insertTable(); this.insertTable();
} }
// Ctrl/Cmd + Shift + Z for Zen mode (only when note is open) // Ctrl/Cmd + Alt/Option + Z for Zen mode
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === 'Z') { if ((e.ctrlKey || e.metaKey) && e.altKey && e.code === 'KeyZ') {
e.preventDefault(); e.preventDefault();
this.toggleZenMode(); this.toggleZenMode();
} }

View File

@ -2063,7 +2063,7 @@
@click="toggleZenMode()" @click="toggleZenMode()"
class="p-2 transition" class="p-2 transition"
style="color: var(--text-secondary);" style="color: var(--text-secondary);"
title="Zen Mode (Ctrl+Shift+Z)" title="Zen Mode (Ctrl+Alt+Z)"
@mouseenter="$el.style.backgroundColor = 'var(--bg-secondary)'" @mouseenter="$el.style.backgroundColor = 'var(--bg-secondary)'"
@mouseleave="$el.style.backgroundColor = 'transparent'" @mouseleave="$el.style.backgroundColor = 'transparent'"
> >