/** * Detects when a specific key is pressed. * Returns a boolean indicating whether the key is currently pressed. * * @param targetKey - The key to detect (e.g., 'Enter', 'Escape', 'a', 'ArrowUp') * @returns Whether the target key is currently pressed * * @example * ```tsx * function SearchInput() { * const [query, setQuery] = useState(''); * const enterPressed = useKeyPress('Enter'); * * useEffect(() => { * if (enterPressed) { * performSearch(query); * } * }, [enterPressed]); * * return setQuery(e.target.value)} />; * } * ``` * * @example * ```tsx * function Modal({ onClose }: { onClose: () => void }) { * const escapePressed = useKeyPress('Escape'); * * useEffect(() => { * if (escapePressed) { * onClose(); * } * }, [escapePressed, onClose]); * * return
Modal content
; * } * ``` * * @example * ```tsx * function Game() { * const wPressed = useKeyPress('w'); * const aPressed = useKeyPress('a'); * const sPressed = useKeyPress('s'); * const dPressed = useKeyPress('d'); * * return ( *
*

W: {wPressed ? 'Pressed' : 'Released'}

*

A: {aPressed ? 'Pressed' : 'Released'}

*

S: {sPressed ? 'Pressed' : 'Released'}

*

D: {dPressed ? 'Pressed' : 'Released'}

*
* ); * } * ``` */ export declare function useKeyPress(targetKey: string): boolean; /** * Detects keyboard shortcuts with modifier keys (Ctrl, Alt, Shift, Meta). * Returns whether the shortcut combination is currently active. * * @param options - Configuration object for the keyboard shortcut * @returns Whether the shortcut is currently active * * @example * ```tsx * function Editor() { * const saveShortcut = useKeyboardShortcut({ key: 's', ctrlKey: true }); * const boldShortcut = useKeyboardShortcut({ key: 'b', metaKey: true }); * * useEffect(() => { * if (saveShortcut) { * handleSave(); * } * }, [saveShortcut]); * * useEffect(() => { * if (boldShortcut) { * toggleBold(); * } * }, [boldShortcut]); * * return