@supunlakmal/hooks
Version:
A collection of reusable React hooks
9 lines (8 loc) • 461 B
TypeScript
/**
* Custom hook for detecting when a specific key is pressed down.
*
* @param {string} targetKey The key to monitor (e.g., 'Enter', 'Escape', 'a', 'ArrowUp').
* Uses `event.key`. See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
* @returns {boolean} Returns `true` if the target key is currently pressed, `false` otherwise.
*/
export declare const useKeyPress: (targetKey: string) => boolean;