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 🙏

© 2025 – Pkg Stats / Ryan Hefner

yubi

v1.0.1

Published

![v](https://badgen.net/npm/v/yubi) ![dt](https://badgen.net/npm/dt/yubi) ![license](https://badgen.net/github/license/kawakamimoeki/yubi)

Readme

Yubi

v dt license

const yubi = new Yubi();
document.addEventListener("keydown", (e) => {
  yubi.record(e);
  if (yubi.match("cmd+k cmd+t")) {
    // Code to be executed when the shortcut is matched
  }
});

Yubi is a powerful library for managing keyboard shortcuts with ease and flexibility. Unlike conventional libraries, Yubi seamlessly integrates with addEventListener, allowing for intuitive and readable shortcut definitions.

It not only supports simultaneous key combinations but also recognizes sequential commands.

Getting Started

To install Yubi, run:

npm install yubi

Then, import it into your project with:

import { Yubi } from "yubi";

Using Yubi is straightforward: create a persistent instance and leverage it in event handlers.

const yubi = new Yubi();

document.addEventListener("keydown", (e) => {
  yubi.record(e); // Capture the event using the Yubi instance

  if (yubi.match("cmd+s")) {
    // Code to be executed when the shortcut is matched
  }
});

For detecting sequences like pressing cmd+k followed by cmd+t, concatenate them with a space:

document.addEventListener("keydown", (e) => {
  yubi.record(e);

  if (yubi.match("cmd+k cmd+t")) {
    // Code to be executed when the sequence is matched
  }
});

Customize the interval for sequential commands and the command delimiter upon instancing.

const yubi = new Yubi({ delay: 500, delimiter: "-" });

// Default settings are { delay: 1000, delimiter: "+" }

String Format

Yubi's hotkey string format allows defining combinations and sequences of keys to trigger specific actions. Key components and examples below illustrate this syntax.

Basic Structure

  1. Modifiers and Keys: Connect modifier keys (e.g., cmd, ctrl) to regular keys (e.g., k, t) using the specified delimiter (default: +).
  2. Sequences: Use space to separate multiple hotkey combinations forming a sequence.

Default Delimiter

  • Combination: cmd+k (Press command and k together)
  • Sequence: cmd+k cmd+t (Press command and k, then command and t)

Custom Delimiter

Change the delimiter by configuring the Yubi instance. For example, with a - delimiter:

  • Combination: cmd-k
  • Sequence: cmd-k cmd-t

Example Modifiers

Modifier Key | Keywords -------------|-------- Alt | Alt, alt, Option, option, ⌥ Ctrl | Ctrl, ctrl, Control, control, ⌃ Shift | Shift, shift, ⇧ Meta | Meta, meta, Command, command, Cmd, cmd, ⌘

Example Arrow Keys

Arrow Key | Keywords --------------|--------- ArrowLeft | left, arrowLeft, ArrowLeft ArrowRight | right, arrowRight, ArrowRight ArrowUp | up, arrowUp, ArrowUp ArrowDown | down, arrowDown, ArrowDown

By altering the delimiter option and structuring your hotkey strings according to the above format, you can craft personalized and versatile key command sequences with Yubi.

Development

To set up the development environment, run:

npm install
npm test

License

This library is distributed under the MIT license. See LICENSE for details.