React Hotkey Tooltip

A global Hotkey provider with built in tooltip for React.

Why you should use it?

When working with hotkeys in a React application we will find many problems when trying to implement it:

  • Hotkeys are only accesible inside a specific component (not globally).
  • Must take care of the hotkeys manually throughout the life cycle.
  • Have to provide a way so the user can see all the hotkeys on the screen.

This library will help you by declaring global hotkeys that automatically will be updated by any life cycle of the component and show a tooltip by pressing a combination of keys ✨

Built with

Why mess up with document.addEventListener or positioning/styling tooltips if there are a lot of open source libraries that can do that for me. This are the chosen ones!

Installation

The library is available as a package in npm and yarn, so use the one you prefer.

# npm
$ npm install react-hotkey-toolip

# yarn
$ yarn add react-hotkey-tooltip

Example

import React from 'react';
import { Hotkey, HotkeyProvider } from 'react-hotkey-tooltip';

const ClickableButtonByPressingA = () => (
  <HotkeyProvider>
    <Hotkey combination="a" onPress="click">
      <button onClick={() => alert('You have clicked me!')}>
        Click me using your keyboard!
      </button>
    </Hotkey>
  </HotkeyProvider>
);

GitHub