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

hotshot

v1.0.5

Published

A teeny tiny keyboard shortcuts library

Downloads

26

Readme

Hotshot.js

A teeny tiny keyboard shortcuts library

Usage

const hotshot = new Hotshot({
  //number of milliseconds we wait for user input before the callback is triggered
  //this is only done if there is also a shortcut with more chars available
  //e.g. if the user pressed gs and gsp is available then we wait
  //otherwise we trigger the callback right away
  waitForInputTime: 500, 
  seqs: [{
    keyCodes: [71, 83],
    callback: () => console.log('TRIGGER', 'G S')
  }, {
    keyCodes: [71, 83, 80],
    callback: () => console.log('TRIGGER', 'G S P')
  }, {
    keyCodes: [91, 13, 71, 83, 80],
    callback: () => console.log('TRIGGER', 'COMMAND ENTER G S P')
  }, {
    keyCodes: [38, 38, 40, 40, 37, 39, 37, 39, 66, 65],
    callback: () => console.log('TRIGGER', '↑ ↑ ↓ ↓ ← → ← → B A')
  }],
  combos: [{
    keyCodes: [91, 66],
    callback: () => console.log('TRIGGER', 'COMMAND+B')
  }]
});

hotshot.bindSeq([65, 66, 71], () => console.log('TRIGGER', 'A B G'));
hotshot.bindCombo([91, 65], () => console.log('TRIGGER', 'COMMAND+A'));

Development

  1. Make sure you have the dev deps installed: yarn i
  2. Run yarn run setup-hooks to setup a pre-push hook that asks you to test before you push
  3. Make your changes in src/ and run yarn run build to build to build/
  4. Run yarn test and make sure all tests still pass

Run yarn run watch to watch for changes in src/Hotshot.js. Run yarn run serve-test to serve the manual test file on localhost:9000/demo.html

Quickly Finding Keycodes

The bindings object works with key codes instead of actual letters for performance reasons. Want to quickly find the key codes you need for your shortcut? Use this jsbin.

Why not use an existing library like Mousetrap?

Mousetrap:

  • Does not currently support a combination of two and three letter sequences (details)
  • Supports IE 6+ which we don't really need. We support IE 11+ at the moment.
  • Spends extra time and code on string character to key code conversion. With Hotshot we went with just using key codes for performance gain.