feat: add copy (Ctrl+C) and exit (Ctrl+D) shortcuts

This commit is contained in:
2026-04-11 01:44:34 +08:00
parent 1aa2c3b9bf
commit 74fa5a52ab
2 changed files with 20 additions and 2 deletions

View File

@@ -17,6 +17,8 @@ All notable changes to this project will be documented in this file.
- **Multi-select delete**: Double-click to enter selection mode, click to toggle selection, batch delete support - **Multi-select delete**: Double-click to enter selection mode, click to toggle selection, batch delete support
- **Title truncation**: Long titles in the list display with ellipsis - **Title truncation**: Long titles in the list display with ellipsis
- **Time display**: Format "time · month/day/year", e.g., "12:45 · 4/11/2026" - **Time display**: Format "time · month/day/year", e.g., "12:45 · 4/11/2026"
- **Copy to clipboard**: Press Ctrl+C to copy current note (title + content)
- **Exit**: Press Ctrl+D to exit (replaces default Ctrl+C)
### Technical ### Technical
@@ -33,4 +35,10 @@ All notable changes to this project will be documented in this file.
```bash ```bash
npm run dev # Development mode npm run dev # Development mode
npm run build # Build to mio.exe npm run build # Build to mio.exe
``` ```
### Keyboard Shortcuts
- `Ctrl+C` - Copy current note to clipboard
- `Ctrl+D` - Exit application
- `Esc` - Exit application (alternative)

View File

@@ -77,10 +77,20 @@ function App() {
const selectedNote = selectedId ? notes.find((n) => n.id === selectedId) : null; const selectedNote = selectedId ? notes.find((n) => n.id === selectedId) : null;
const handleCopy = () => {
if (selectedNote) {
const text = `${selectedNote.title}\n\n${selectedNote.content}`;
process.stdout.write('\x1b]52;c;' + btoa(text) + '\x07');
}
};
useKeyboard((key) => { useKeyboard((key) => {
if (key.name === "escape") { if (key.ctrl && key.name === "d") {
process.exit(0); process.exit(0);
} }
if (key.ctrl && key.name === "c") {
handleCopy();
}
}); });
return ( return (