react-combo-keys
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

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} />;
}

Package Sidebar

Install

npm i react-combo-keys

Weekly Downloads

2,033

Version

2.1.0

License

MIT

Unpacked Size

19.3 kB

Total Files

11

Last publish

Collaborators

  • samypesse