aboutsummaryrefslogtreecommitdiff
path: root/apps/web/lib
diff options
context:
space:
mode:
authorDhravya Shah <[email protected]>2024-08-06 11:05:02 -0700
committerDhravya Shah <[email protected]>2024-08-06 11:05:02 -0700
commitbe3e13b4bfb847af410f2159be462cc912141fc3 (patch)
treea3783a7e7798de60f599ea0f0a5db24c5c30395f /apps/web/lib
parentchanges for prod (diff)
parentMerge pull request #219 from Deepakchowdavarapu/readme-issue (diff)
downloadsupermemory-be3e13b4bfb847af410f2159be462cc912141fc3.tar.xz
supermemory-be3e13b4bfb847af410f2159be462cc912141fc3.zip
merged latest changes with queue branch and ready for prod
Diffstat (limited to 'apps/web/lib')
-rw-r--r--apps/web/lib/useKeyPress.ts15
1 files changed, 15 insertions, 0 deletions
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]);
+};