diff --git a/apps/extension/content/ContentApp.tsx b/apps/extension/content/ContentApp.tsx index c0339897..a510a77c 100644 --- a/apps/extension/content/ContentApp.tsx +++ b/apps/extension/content/ContentApp.tsx @@ -131,6 +131,13 @@ export default function ContentApp({ }); } }); + const handleKeyDown = (e: KeyboardEvent) => { + if (isPopoverOpen) { + e.stopPropagation(); + e.preventDefault(); + } + }; + document.addEventListener("keydown", handleKeyDown, true); const portalDiv = document.createElement("div"); portalDiv.id = "popover-portal"; @@ -139,6 +146,7 @@ export default function ContentApp({ return () => { document.removeEventListener("mousemove", () => {}); + document.removeEventListener("keydown", handleKeyDown, true); }; }, []); diff --git a/apps/web/app/(dash)/menu.tsx b/apps/web/app/(dash)/menu.tsx index 70439c7d..c1173eb6 100644 --- a/apps/web/app/(dash)/menu.tsx +++ b/apps/web/app/(dash)/menu.tsx @@ -30,6 +30,7 @@ import { createMemory, createSpace } from "../actions/doers"; import ComboboxWithCreate from "@repo/ui/shadcn/combobox"; import { StoredSpace } from "@/server/db/schema"; import useMeasure from "react-use-measure"; +import { useKeyPress } from "@/lib/useKeyPress"; function Menu() { const [spaces, setSpaces] = useState([]); @@ -48,7 +49,11 @@ function Menu() { setSpaces(spaces.data); })(); }, []); - + useKeyPress("a", () => { + if (!dialogOpen) { + setDialogOpen(true); + } + }); const menuItems = [ { icon: HomeIconWeb, diff --git a/apps/web/app/(thinkpad)/thinkpad/page.tsx b/apps/web/app/(thinkpad)/thinkpad/page.tsx index defa8e43..a4f71f29 100644 --- a/apps/web/app/(thinkpad)/thinkpad/page.tsx +++ b/apps/web/app/(thinkpad)/thinkpad/page.tsx @@ -37,7 +37,7 @@ async function page() {

- *this is under beta and only one canvas is allowed per user + Thinkpads is under beta and only one thinkpad is allowed per user.

); diff --git a/apps/web/lib/useKeyPress.ts b/apps/web/lib/useKeyPress.ts new file mode 100644 index 00000000..eee23acb --- /dev/null +++ b/apps/web/lib/useKeyPress.ts @@ -0,0 +1,15 @@ +import { useEffect } from "react"; + +export const useKeyPress = (key: string, callback: () => void) => { + useEffect(() => { + const handler = (e: KeyboardEvent) => { + if (e.key === key && e.altKey) { + callback(); + } + }; + window.addEventListener("keydown", handler); + return () => { + window.removeEventListener("keydown", handler); + }; + }, [key, callback]); +};