2.0.4 • Published 3 years ago

react-hook-mousetrap v2.0.4

Weekly downloads
531
License
ISC
Repository
github
Last release
3 years ago

react-hook-mousetrap

A quick react hook to trigger actions on specific key combination. It uses mousetrap to do the job, so any mousetrap combo or array of combo can be passed as option.

Import it like this :

import useMousetrap from "react-hook-mousetrap"

Then in your component :

// useMousetrap(<Keys>, <Callback>)
useMousetrap("ctrl+enter", // any mousetrap combo, or array of combo

      () => { // triggered on key combo
        // whatever. You can use your state in there too.
      });

NOTE : If you want to trap keys in an input or textarea you need to add the mousetrap class to the element : className="mousetrap"

2.0.4

3 years ago

2.0.3

4 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago