1.0.1 • Published 3 years ago

@missspopcorn/keyboard-shortcuts v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Keyboard Shortcuts

A library to bind keyboard shortcuts in your React App.

  • Take Key combination as input
  • Suppports callback for the key shortcut you like

  • Install by executing npm install @missspopcorn/keyboard-shortcuts.

  • Import by adding import { KeyboardShortcuts } from "@missspopcorn/keyboard-shortcuts'.
  • Use by adding <KeyboardShortcut />.

Demo

A minimal demo can be found in components directory and App.js.

Code

The code for this library can be found in utils directory.

Online demo is also available!

Getting started

Compatibility

Your project needs to use React 16.8 or later.

@missspopcorn/keyboard-shortcut uses modern web technologies. That's why it's so fast, and lightweight.

Installation

Add this library to your project by executing npm install @missspopcorn/keyboard-shortcuts

Usage

Here's an example of basic usage:

import { KeyboardShortcut } from "@missspopcorn/keyboard-shortcuts";

function MyApp() {

  return (
    <div>
       <KeyboardShortcut
        combo="shift b"
        callback={() => function()}
        description="The shortcut description"
      ></KeyboardShortcut>
    </div>
  );
}

To list all keyboard shortcuts passed to the components:

import { withKeyboardShortcuts } from '@missspopcorn/keyboard-shortcuts'


 function Component({
   keyboardShortcuts
 }) {
 }
 withKeyboardShortcut(Component)

License

The MIT License.

Author

Thank you