Home

Awesome

react-combo-keys

Build Status NPM version

Declarative API with React to bind keyboard shortcuts using Mousetrap.

Installation

$ yarn add react-combo-keys

Usage

import * as React from 'react';
import { useComboKeys } from 'react-combo-keys';

function SearchBar(props: {}) {
    const input = Rwact.useRef();

    useComboKeys({
        'Mod+F': () => {
            input.current.focus();
        },
        'Mod+': () => {
            alert('Settings !')
        }
    }, {}, []);

    return <input type="text" ref={input} />;
}