diff --git a/src/renderer/components/SearchPopup.tsx b/src/renderer/components/SearchPopup.tsx index 08a3a01..19ab4fd 100644 --- a/src/renderer/components/SearchPopup.tsx +++ b/src/renderer/components/SearchPopup.tsx @@ -67,6 +67,7 @@ export default function SearchPopup({ onClose }: Props) { className="bg-gray-100 mx-5 px-3 rounded text-xs py-2 outline-none focus:outline focus:outline-1 focus:outline-green-500" value={searchQuery} onChange={(e) => setSearchQuery(e.target.value)} + autoFocus={true} />
diff --git a/src/renderer/components/Sidebar.tsx b/src/renderer/components/Sidebar.tsx index 148739b..96f291c 100644 --- a/src/renderer/components/Sidebar.tsx +++ b/src/renderer/components/Sidebar.tsx @@ -1,4 +1,4 @@ -import { Fragment, useState } from 'react'; +import { Fragment, useEffect, useState } from 'react'; import { GoFile, GoGear, @@ -29,6 +29,22 @@ export default function Sidebar() { const { notes, handleCreateNewNote } = useNotes(); const { handleChangeDir } = useDir(); + function handleShortcuts(e: KeyboardEvent) { + if (e.ctrlKey && e.key === 's') { + setShowSearchPopup(true); + } + + // if (e.ctrlKey && e.key === 'n') { + // handleCreateNewNote(); + // } + } + + useEffect(() => { + document.addEventListener('keydown', handleShortcuts); + + return () => document.removeEventListener('keydown', handleShortcuts); + }, []); + return (