react-use-shortcut
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

react-use-shortcut

React keyboard shortcut hook.

Install

npm install --save react-use-shortcut

Usage

import useShortcut from 'react-use-shortcut'
 
const FunctionalComponent = props => {
    const submitForm = keyboardEvent => console.log('submitForm', keyboardEvent)
    const runsBeforeSubmit = keyboardEvent => console.log('runsBeforeSubmit', keyboardEvent)
 
    useShortcut('ctrl+shift+e', submitForm)
    useShortcut('enter', submitForm)
 
    // set with priority
    useShortcut('ctrl+shift+e', runsBeforeSubmit, 10)
    useShortcut('enter', runsBeforeSubmit, 10)
}

License

License: MIT

Package Sidebar

Install

npm i react-use-shortcut

Weekly Downloads

4

Version

0.1.1

License

MIT

Unpacked Size

9.42 kB

Total Files

7

Last publish

Collaborators

  • afirus