Use Key Capture
DemoDocsInstallationHow it is usedPropertiesTarget Prop getterProps

use-key-capture

use-key-capture is a custom hook which will let us not to worry about the key-press event. Just plugin in use-key-capture hook to the target we want to listen for key press event or by default it can listen for key-press event globally.

Installation

npm

npm i use-key-capture

yarn

yarn add use-key-capture

How it is used

import useKey from 'use-key-capture';
...
const { keyData, resetKeyData, getTargetProps } = useKey();

Properties

Property nameDescription
keyDatagives pressed key details
resetKeyDataresets the pressed key details

Target Prop getter

Property nameDescription
getTargetPropsgives the required props to target element