55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { useRouter } from "next/navigation";
|
|
import { useMemo } from "react";
|
|
import { useKeyboardShortcuts, type KeyboardShortcut } from "@/lib/use-keyboard-shortcuts";
|
|
|
|
export function KeyboardShortcuts() {
|
|
const router = useRouter();
|
|
|
|
const shortcuts = useMemo<KeyboardShortcut[]>(
|
|
() => [
|
|
{
|
|
key: "n",
|
|
meta: true,
|
|
handler: () => router.push("/workspaces"),
|
|
description: "Open workspaces",
|
|
},
|
|
{
|
|
key: "d",
|
|
meta: true,
|
|
shift: true,
|
|
handler: () => router.push("/dashboard"),
|
|
description: "Go to dashboard",
|
|
},
|
|
{
|
|
key: "r",
|
|
meta: true,
|
|
shift: true,
|
|
handler: () => router.push("/reviews"),
|
|
description: "Go to reviews",
|
|
},
|
|
{
|
|
key: "a",
|
|
meta: true,
|
|
shift: true,
|
|
handler: () => router.push("/prompts"),
|
|
description: "Open Smart Actions",
|
|
},
|
|
{
|
|
key: "Escape",
|
|
handler: () => {
|
|
const active = document.activeElement as HTMLElement | null;
|
|
active?.blur();
|
|
},
|
|
description: "Dismiss / blur",
|
|
},
|
|
],
|
|
[router],
|
|
);
|
|
|
|
useKeyboardShortcuts(shortcuts);
|
|
|
|
return null;
|
|
}
|