From 74fa5a52abb84afe01987c2d13027785c4d29bf9 Mon Sep 17 00:00:00 2001 From: "Z.To" Date: Sat, 11 Apr 2026 01:44:34 +0800 Subject: [PATCH] feat: add copy (Ctrl+C) and exit (Ctrl+D) shortcuts --- changelog.md | 10 +++++++++- src/index.tsx | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 010c290..0873bd2 100644 --- a/changelog.md +++ b/changelog.md @@ -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 - **Title truncation**: Long titles in the list display with ellipsis - **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 @@ -33,4 +35,10 @@ All notable changes to this project will be documented in this file. ```bash npm run dev # Development mode npm run build # Build to mio.exe -``` \ No newline at end of file +``` + +### Keyboard Shortcuts + +- `Ctrl+C` - Copy current note to clipboard +- `Ctrl+D` - Exit application +- `Esc` - Exit application (alternative) \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 8e3dc99..47142e6 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -77,10 +77,20 @@ function App() { 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) => { - if (key.name === "escape") { + if (key.ctrl && key.name === "d") { process.exit(0); } + if (key.ctrl && key.name === "c") { + handleCopy(); + } }); return (