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

@@ -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 (