Keyboard & Input
useKeyRef
About
Very similar useKey but it returns a ref
Examples
Basic example with keydown
Multiple handlers on the same element
Multiple kinds of events
Conditionally setting handlers
Arguments
| Argument value | Type | Description | Defualt | 
|---|---|---|---|
| keyList | Array | A list of keys to listen | undefined | 
| callback | Function | Callback function to be called when event is triggered | undefined | 
| options | Object | See table below | undefined | 
| Options value | Type | Description | Defualt | 
|---|---|---|---|
| when | Boolean | Condition which if true, will enable the event listeners | true | 
| eventTypes | Array of number or string | Keyboardevent types to listen for. Valid options are keyDown, keyPress and keyUp | ['keydown'] | 
Returns
| Return value | Type | Description | Defualt | 
|---|---|---|---|
| ref | Callback Ref | A ref that can be used on the element you want to listen | undefined |