A hook which allows to setup callbacks when a combination of keys are pressed at the same time.
An important difference between useKey
and useKeys
is that useKey
checks if EITHER of the keys in the list is pressed, while useKeys
checks if ALL of the keys in the list are active.
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'] |
target | HTMLElement ref | target ref on which the events should be listened. | window |
preventLostKeyup | Boolean | Prevent keyup events get lost tracking when alert is triggered. | false |
No return value
Join our discord server! You can click the floating discord icon at the bottom right of the screen and chat with us!