use-keyboard
v1.0.2
Published
An easy-to-use keyboard hook for react applications.
Downloads
2
Maintainers
Readme
useKeyboard
An react hook for handling keyboard input.
This package is under development and is not production-ready.
Install
npm i use-keyboard
or
yarn add use-keyboard
Basic usage
const { pressed } = useKeyboard();
const spacePressed = pressed("Space");
Axis abstraction
const { axis } = useKeyboard();
const horizontal = axis("LeftArrow", "RightArrow");
};
Key handlers
const _keyboard = useKeyboard({
down: {
Space: () => console.log("Spacebar pressed"),
},
up: {
Space: () => console.log("Spacebar released"),
},
});