useHotkeys ​
Hook that listens for hotkeys
typescript
import { useHotkeys } from '@elysiumorg/solid-use';Usage ​
typescript
useHotkeys('control+a', () = > console.log('hotkey pressed'));
Demo ​
Api ​
Parameters
| Name | Type | Default | Note | 
|---|---|---|---|
| hotkeys | UseHotkeysHotkeys | - | The key or keys to listen for | 
| callback | (event: KeyboardEvent) => void | - | The callback function to be called when the hotkey is pressed | 
| options.target? | UseEventListenerTarget | window | The target to attach the event listeners to | 
| options.enabled? | boolean | true | Enable or disable the event listeners | 
| options.preventDefault? | boolean | true | Whether to prevent the default behavior of the event | 
| options.aliasMap? | Record<string, string> | - | Alias map for hotkeys |