diff --git a/README.md b/README.md index e42abb2f..18956d92 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ - [`useGeolocation`](./docs/useGeolocation.md) — tracks geo location state of user's device. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usegeolocation--demo) - [`useHover` and `useHoverDirty`](./docs/useHover.md) — tracks mouse hover state of some element. [![][img-demo]](https://codesandbox.io/s/zpn583rvx) - [`useIdle`](./docs/useIdle.md) — tracks whether user is being inactive. - - [`useKey`](./docs/useKey.md), [`useKeyPress`](./docs/useKeyPress.md), and [`useKeyPressEvent`](./docs/useKeyPressEvent.md) — track keys. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usekeypressevent--demo) + - [`useKey`](./docs/useKey.md), [`useKeyPress`](./docs/useKeyPress.md), [`useKeyPressEvent`](./docs/useKeyPressEvent.md), and [`useKeyboardJs`](./docs/useKeyboardJs.md) — track keys. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usekeypressevent--demo) - [`useLocation`](./docs/useLocation.md) — tracks page navigation bar location state. - [`useMedia`](./docs/useMedia.md) — tracks state of a CSS media query. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usemedia--demo) - [`useMediaDevices`](./docs/useMediaDevices.md) — tracks state of connected hardware devices. diff --git a/docs/useKeyPress.md b/docs/useKeyPress.md index 4cd43895..e7955115 100644 --- a/docs/useKeyPress.md +++ b/docs/useKeyPress.md @@ -3,11 +3,6 @@ React UI sensor hook that detects when the user is pressing a specific key on their keyboard. -Complex bindings like detecting when multiple keys are held down at the same -time or requiring them to be held down in a specified order are also available -via [KeyboardJS key combos](https://github.com/RobertWHurst/KeyboardJS). -Check its documentation for further details on how to make combo strings. - ## Usage diff --git a/docs/useKeyboardJs.md b/docs/useKeyboardJs.md new file mode 100644 index 00000000..a00700b2 --- /dev/null +++ b/docs/useKeyboardJs.md @@ -0,0 +1,31 @@ +# `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 ( +
{combo} combo
+