mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
32 lines
645 B
Markdown
32 lines
645 B
Markdown
# `useKeyboardJs`
|
|
|
|
React UI sensor hook that detects complex key combos like detecting when
|
|
multiple keys are held down at the same time or requiring them to be held down in a specified order.
|
|
|
|
Via [KeyboardJS key combos](https://github.com/RobertWHurst/KeyboardJS).
|
|
Check its documentation for further details on how to make combo strings.
|
|
|
|
|
|
## Usage
|
|
|
|
```jsx
|
|
import useKeyboardJs from 'react-use/lib/useKeyboardJs';
|
|
|
|
const Demo = () => {
|
|
const isPressed = useKeyboardJs('a + b');
|
|
|
|
return (
|
|
<div>
|
|
[a + b] pressed: {isPressed ? 'Yes' : 'No'}
|
|
</div>
|
|
);
|
|
};
|
|
```
|
|
|
|
|
|
## Examples
|
|
|
|
```js
|
|
const isPressed = useKeyboardJs('a + b');
|
|
```
|