MCPcopy Create free account
hub / github.com/alanagoyal/docbase / down

Function down

components/command-menu.tsx:54–76  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

52
53 useEffect(() => {
54 const down = (e: KeyboardEvent) => {
55 if (!isTyping()) {
56 if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
57 e.preventDefault();
58 setOpen((open) => !open);
59 } else {
60 const pressedKey = e.key.toLowerCase();
61 const allItems = [...menuItems, ...mainNavItems];
62 const matchedItem = allItems.find(item => item.shortcut.toLowerCase() === pressedKey);
63
64 if (matchedItem) {
65 e.preventDefault();
66 if (matchedItem.href) {
67 navigateAndCloseDialog(matchedItem.href);
68 } else if (matchedItem.action === 'theme') {
69 setTheme(theme === "light" ? "dark" : "light");
70 } else if (matchedItem.action === 'logout') {
71 handleSignOut();
72 }
73 }
74 }
75 }
76 };
77
78 document.addEventListener("keydown", down);
79 return () => document.removeEventListener("keydown", down);

Callers

nothing calls this directly

Calls 2

isTypingFunction · 0.70
handleSignOutFunction · 0.70

Tested by

no test coverage detected