Files
homelab-optimized/dashboard/ui/components/keyboard-shortcuts.tsx
Gitea Mirror Bot 57b1fe47f2
Some checks failed
Documentation / Deploy to GitHub Pages (push) Has been cancelled
Documentation / Build Docusaurus (push) Has been cancelled
Sanitized mirror from private repository - 2026-04-19 08:15:48 UTC
2026-04-19 08:15:48 +00:00

30 lines
956 B
TypeScript

"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";
export function KeyboardShortcuts() {
const router = useRouter();
useEffect(() => {
function handler(e: KeyboardEvent) {
// Don't trigger when typing in inputs
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return;
switch (e.key) {
case "1": router.push("/"); break;
case "2": router.push("/infrastructure"); break;
case "3": router.push("/media"); break;
case "4": router.push("/automations"); break;
case "5": router.push("/expenses"); break;
case "6": router.push("/network"); break;
case "7": router.push("/logs"); break;
case "r": window.location.reload(); break;
}
}
window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler);
}, [router]);
return null;
}