useKeyPress
Events
A React hook that detects when a specific key is pressed and held down, returning true while pressed and false when released.
Installation
npm install @thibault.sh/hooks
API Reference
Signature
function useKeyPress(targetKey: string): boolean
Parameters
Name | Type | Description | Default |
---|---|---|---|
targetKey | string | The key to detect (e.g., 'Enter', 'Escape', 'ArrowUp', 'a'). | - |
Returns
boolean
Boolean indicating if the target key is currently pressed.