MCPcopy Create free account
hub / github.com/triggerdotdev/trigger.dev / useShortcutKeys

Function useShortcutKeys

apps/webapp/app/hooks/useShortcutKeys.tsx:26–49  ·  view source on GitHub ↗
({
  shortcut,
  action,
  disabled = false,
  enabledOnInputElements,
}: useShortcutKeysProps)

Source from the content-addressed store, hash-verified

24};
25
26export function useShortcutKeys({
27 shortcut,
28 action,
29 disabled = false,
30 enabledOnInputElements,
31}: useShortcutKeysProps) {
32 const { platform } = useOperatingSystem();
33 const isMac = platform === "mac";
34 const relevantShortcut =
35 shortcut && "mac" in shortcut ? (isMac ? shortcut.mac : shortcut.windows) : shortcut;
36
37 const keys = createKeysFromShortcut(relevantShortcut);
38 useHotkeys(
39 keys,
40 (event, hotkeysEvent) => {
41 action(event);
42 },
43 {
44 enabled: !disabled,
45 enableOnFormTags: enabledOnInputElements ?? relevantShortcut?.enabledOnInputElements,
46 enableOnContentEditable: enabledOnInputElements ?? relevantShortcut?.enabledOnInputElements,
47 }
48 );
49}
50
51function createKeysFromShortcut(shortcut: Shortcut | undefined) {
52 if (!shortcut) {

Callers 5

Buttons.tsxFile · 0.90
LinkButtonFunction · 0.90
SelectTriggerFunction · 0.90
SelectItemFunction · 0.90
ShortcutWithActionFunction · 0.90

Calls 4

useOperatingSystemFunction · 0.90
createKeysFromShortcutFunction · 0.85
useHotkeysFunction · 0.85
actionFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…