useKeyBind
TODO
Usage
useKeyBind(element, bindings)
Parameters
-
element/ref {EventTarget} - An EventTarget or a
React.createRef()
to apply keybindings. -
bindings {object} - An object that maps keybindings to their respective functions.
// binding: callbackFn or callbackFn[] 'ctrl+t': onOpenTab 'ctrl+shift+s': onSave onSubmit inputRefcurrent
Example
import useKeyBind from 'use-keybind'; { const onSave = /* ... */ const onSubmit = /* ... */ const adminRef = ; ; return <Admin => <UserInfoSection> <Form ='user-info'> /* ... */ </Form> </UserInfoSection> </Admin> ;}
Supported Keys
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values