diff --git a/src/renderer/hooks/use-shortcut.ts b/src/renderer/hooks/use-shortcut.ts new file mode 100644 index 0000000..690468b --- /dev/null +++ b/src/renderer/hooks/use-shortcut.ts @@ -0,0 +1,96 @@ +import { useEffect } from 'react'; + +/** + * Bind a keyboard shortcut to a callback. + * + * Combos use `+` separators. Tokens: + * - `mod` → meta (Mac) or ctrl (others) + * - `ctrl` → ctrl only + * - `meta` → meta only + * - `alt` → alt / option + * - `shift` → shift + * - any single char (case-insensitive), e.g. `s`, `S` + * - special names: `Tab`, `Enter`, `Escape`, `Space`, `ArrowUp/Down/Left/Right` + * + * The hook is suppressed when the keydown target is an ``, `