Content
useKeyPress
Custom hook to detect if a specified key is pressed.
useKeyPress
Usage
API
useKeyPress
Returns boolean value indicating whether the specified key combination is currently pressed.
Parameters
Name | Type | Description |
---|---|---|
options | KeyConfig | The configuration for the key press detection. |
options.key | string | The key to listen for. |
options.ctrl | boolean | Whether the Ctrl key must be pressed. Optional. |
options.alt | boolean | Whether the Alt key must be pressed. Optional. |
options.shift | boolean | Whether the Shift key must be pressed. Optional. |
Returns
Name | Type | Description |
---|---|---|
keyPressed | boolean | true if the specified key combination is currently pressed, false otherwise. This value is updated whenever the key combination is pressed or released. |