UNPKG

qol-hooks

Version:

A collection of React hooks to improve the quality of life of developers.

19 lines (18 loc) 491 B
/** * Custom hook to detect if a specific key is pressed. * @param {string} targetKey - The key to detect. * @returns {boolean} Whether the key is currently pressed or not. * * @example```tsx * const Component = () => { * const isKeyPressed = useKeyPress("Enter"); * * return ( * <div> * {isKeyPressed ? "Enter key is pressed" : "Enter key is not pressed"} * </div> * )}; * ``` */ declare function useKeyPress(targetKey: string): boolean; export default useKeyPress;