Nonvoluntary Professional Mangling

    react-hook-mousetrap
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/react-hook-mousetrap package

    2.0.4 • Public • Published

    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"

    Install

    npm i react-hook-mousetrap

    DownloadsWeekly Downloads

    1,225

    Version

    2.0.4

    License

    ISC

    Unpacked Size

    2.33 kB

    Total Files

    3

    Last publish

    Collaborators

    • olup