diff --git a/packages/core/src/hooks/hotkeys/use-hotkeys.md b/packages/core/src/hooks/hotkeys/use-hotkeys.md index 6d580088db..6e36a9641c 100644 --- a/packages/core/src/hooks/hotkeys/use-hotkeys.md +++ b/packages/core/src/hooks/hotkeys/use-hotkeys.md @@ -78,6 +78,8 @@ and configure the ? key to open the generated hotkeys dialog, but it event handlers with the returned `handleKeyDown` and `handleKeyUp` functions. The hook takes an optional second parameter which can customize some of its default behavior. +@interface UseHotkeysOptions + @method useHotkeys @interface HotkeyConfig diff --git a/packages/core/src/hooks/hotkeys/useHotkeys.ts b/packages/core/src/hooks/hotkeys/useHotkeys.ts index 813dc4563c..7f33d540aa 100644 --- a/packages/core/src/hooks/hotkeys/useHotkeys.ts +++ b/packages/core/src/hooks/hotkeys/useHotkeys.ts @@ -21,6 +21,14 @@ import { HotkeysContext } from "../../context"; import { HotkeyConfig } from "./hotkeyConfig"; export interface UseHotkeysOptions { + /** + * A custom document to reference when binding global event handlers. + * This can be useful when using iframes in an application. + * + * @default window.document + */ + document?: Document; + /** * The key combo which will trigger the hotkeys dialog to open. * @@ -41,7 +49,7 @@ export interface UseHotkeysReturnValue { * @param options hook options */ export function useHotkeys(keys: HotkeyConfig[], options: UseHotkeysOptions = {}): UseHotkeysReturnValue { - const { showDialogKeyCombo = "?" } = options; + const { document = window.document, showDialogKeyCombo = "?" } = options; const localKeys = React.useMemo( () => keys