npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vulcancreative/keyboard-event-bus

v1.0.2

Published

A lightweight package for handling keyboard events and triggering user-defined actions in React applications

Downloads

2

Readme

Keyboard Event Bus

A lightweight package for handling keyboard events and triggering user-defined actions in React applications

Demo

https://vulcancreative.github.io/keyboard-event-bus/

Instalation

npm install @vulcancreative/keyboard-event-bus

or

yarn add @vulcancreative/keyboard-event-bus

How to use

Wrap your React app with KeyboardEventBusProvider

import {KeyboardEventBusProvider} from "@vulcancreative/keyboard-event-bus";

<KeyboardEventBusProvider>
  <App />
</KeyboardEventBusProvider>

Inside your React app, use the useKeyboardEventBus hook to add new shortcut.

import { useKeyboardEventBus, Key } from "@vulcancreative/keyboard-event-bus";

const App = () => {
  const shortcut = useKeyboardEventBus();

  useEffect(() => {
    const removeShortcut = shortcut?.add([Key.CMD_CTRL, Key.SHIFT, Key.CHAR_K], () => {
      alert("This will show when you hit your shortcut");
    });
    return () => {
      if (removeShortcut) {
        removeShortcut();
      }
    }
  }, []);
}

The useKeyboardEventBus's add method returns a callback to remove the shortcut from the keyboard event bus list. Use it when you want to remove the shortcut, for example on component re-render.

List of available keys

| Key | Description | |-------------|---------------| | SHIFT_LEFT | Left Shift | | SHIFT_RIGHT | Right Shift | | SHIFT | All Shift | | TAB | Tab | | CTRL_LEFT | Left Control | | CTRL_RIGHT | Right Control | | CTRL | Control | | CMD_CTRL | Command / Control (Use Command on MacOs and Control on Windows)| | ALT_LEFT | Left Alt | | ALT_RIGHT | Right Alt | | ALT | All Alt | | CMD_LEFT | Left Meta / Command | | CMD_RIGHT | Right Meta / Command | | CMD | All Meta / Command | | BACKSPACE | Backspace | | ENTER | Enter | | CAPSLOCK | CapsLock | | CHAR_A | a | | CHAR_B | b | | CHAR_C | c | | CHAR_D | d | | CHAR_E | e | | CHAR_F | f | | CHAR_G | g | | CHAR_H | h | | CHAR_I | i | | CHAR_J | j | | CHAR_K | k | | CHAR_L | l | | CHAR_M | m | | CHAR_N | n | | CHAR_O | o | | CHAR_P | p | | CHAR_Q | q | | CHAR_R | r | | CHAR_S | s | | CHAR_T | t | | CHAR_U | u | | CHAR_V | v | | CHAR_W | w | | CHAR_X | x | | CHAR_Y | y | | CHAR_Z | z | | NUM_0 | 0 | | NUM_1 | 1 | | NUM_2 | 2 | | NUM_3 | 3 | | NUM_4 | 4 | | NUM_5 | 5 | | NUM_6 | 6 | | NUM_7 | 7 | | NUM_8 | 8 | | NUM_9 | 9 | | BACKQUOTE | ` | | SLASH | / | | BACKSLASH | \ |