@mastry/use-key-toggle
v1.0.0
Published
Toggle state with a key press
Downloads
1
Readme
use-key-toggle
A simple React hook to toggle a boolean flag with a key press.
Installation
npm i @mastry/use-key-toggle
Usage
import React from 'react'
import useKeyToggle from 'use-key-toggle'
const MyComponent: React.FC = () => {
const [isOpen] = useKeyToggle('KeyK', false);
return <>Press CTRL+K to change state. The current state is {isOpen}</>
}