import { type KeyCode } from '@xyflow/system'; export type UseKeyPressOptions = { /** * Listen to key presses on a specific element. * @default document */ target?: Window | Document | HTMLElement | ShadowRoot | null; /** * You can use this flag to prevent triggering the key press hook when an input field is focused. * @default true */ actInsideInputWithModifier?: boolean; preventDefault?: boolean; }; /** * This hook lets you listen for specific key codes and tells you whether they are * currently pressed or not. * * @public * @param options - Options * * @example * ```tsx *import { useKeyPress } from '@xyflow/react'; * *export default function () { * const spacePressed = useKeyPress('Space'); * const cmdAndSPressed = useKeyPress(['Meta+s', 'Strg+s']); * * return ( *
Space pressed!
} * {cmdAndSPressed &&Cmd + S pressed!
} *