useKeyboard ​
Hook that help to listen for keyboard events
typescript
import { useKeyboard } from '@siberiacancode/reactuse';
Usage ​
typescript
useKeyboard({ onKeyDown: () => console.log('key down'), onKeyUp: () => console.log('key up') })
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
target? | UseEventListenerTarget | window | The target to attach the event listeners to |
onKeyDown? | (event: KeyboardEvent) => void | - | The callback function to be invoked on key down |
onKeyUp? | (event: KeyboardEvent) => void | - | The callback function to be invoked on key up |