Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including react-mousetrap with all npm packages installed. Try it out:

require("react/package.json"); // react is a peer dependency. require("react-dom/package.json"); // react-dom is a peer dependency. require("react-polyfills/package.json"); // react-polyfills is a peer dependency. var reactMousetrap = require("react-mousetrap")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

react-mousetrap v0.2.0

HOC builder for Mousetrap

react-mousetrap Build Status npm version

React's high order component for Mousetrap integration.

Setup

Yarn install

yarn add react-mousetrap

Example

Create higher order component

import mouseTrap from 'react-mousetrap';

class YourComponent extends React.Component {
    /*your implementation */

    componentWillMount {
        this.props.bindShortcut('right', this._goToNext);
    }

    _goToNext() {
        this.props.unbindShortcut('right');
    }
}

export default mouseTrap(BaseComponent);
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free