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

@simulacron/keyboard

v1.0.1

Published

Helper classes and functions for working with the keyboard

Downloads

5

Readme

Keyboard helpers

Helper classes and functions for working with the keyboard.

KeyboardShortcut

Class for handling keyboard shortcut. Typically used in browser keyboard event handlers.

You must instantiate the class with the keyboard shortcut, and then use the isMatchEvent() method to test for the keyboard event:

const shortcut = new KeyboardShortcut('mod+s');

element.addEventListener('keydown', function(event) {
  if (shortcut.isMatchEvent(event)) {
    // Do action...
  }
});

Keyboard shortcuts format

Keyboard shortcuts are specified using a simple format such as 'modifier+key', 'modifier+modifier+key', or simply 'key'.

Modifiers can be:

  • mod - cross-platform modifier, Ctrl on Windows and Cmd on Mac;
  • ctrl, ctl - Control on Windows;
  • alt, opt, option - Alt;
  • shift - Shift;
  • meta - cross-platform modifier, Win on Windows, Cmd on Mac;
  • win, windows - Win on Windows;
  • cmd, command - Cmd on Mac.

Key is any value from the predefined KeyboardEvent.key keys, specified in any case.

The class provides some aliases for the keys from the KeyboardEvent, such as:

  • esc - 'Escape' key;
  • return - 'Enter' key;
  • space, spacebar - 'spacebar' key;
  • add - '+' key;
  • break - 'Pause' key;
  • ins - 'Insert' key;
  • del - 'Delete' key;
  • up - 'ArrowUp' key;
  • down - 'ArrowDown' key;
  • left - 'ArrowLeft' key;
  • right - 'ArrowRight' key.

This class is inspired by the is-hotkey package from Ian Storm Taylor https://github.com/ianstormtaylor

KeyboardShortcuts

A class for handling multiple keyboard shortcuts.

It is used when it is necessary to use one handler for several keyboard shortcuts.

const shortcuts = new KeyboardShortcuts([
  'mod+s',
  'ctrl+k',
]);

element.addEventListener('keydown', function(event) {
  if (shortcuts.isMatchEvent(event)) {
    // Do action...
  }
});

See KeyboardShortcut for details.