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

shortcut.js

v2.0.3

Published

shortcut.js [![Code Climate](https://codeclimate.com/github/blainekasten/shortcut.js/badges/gpa.svg)](https://codeclimate.com/github/blainekasten/shortcut.js) [![Circle CI](https://circleci.com/gh/blainekasten/shortcut.js.svg?style=svg&circle-token=b2b274

Downloads

9

Readme

shortcut.js Code Climate Circle CI

Documentation for v1 is found here

Ever wanted to add keyboard shortcuts to your website, but couldnt justify the time to develop it?

Shortcut.js gives you easy access to add shortcuts to your already existing functions.

Features!

  • Chainable
  • Global and Individual pause/resume functions
  • Cross OS Key Bindings ('mod' key)
  • CrossBrowser (IE8+, Chrome, FF, Safari Tested)
  • UMD compatibility

Installation

bower install shortcut npm install shortcut.js

How to use

General
function uppercaseInput(e){...}
function validateInput(e){...}

shortcut('mod =', document.querySelector('input#uppercase'))
  .bindsTo(uppercaseInput)
  .bindsTo(validateInput);

Here, when a user presses the the modifier key with the equals key, we run an uppercaseInput function, and then a validateInput function.

API

shortcut(shortcutKeys, DOMNode)

  • String shortcutKeys: A space delimited set of keys to press. For special keys, use the following mappings: shift, meta, optn, ctrl, space, down, right, up, left, tab, rtn

  • HTMLElement DOMNode: The DOMNode you want the shortcuts to trigger on.

+pause()

This function globally pauses all shortcut function dispatching. Keyboard shortcuts pressed after this function will not fire their associated functions.

Useage:

shortcut.pause();

+resume()

This function globally resumes all shortcut function dispatching. Keyboard shortcuts pressed after this function WILL fire their associated functions.

Useage:

shortcut.resume();

-bindsTo(fn: Function)

  • Function fn: A function which gets ran when the shortcutKeys are pressed in the appropriate selector.

-preventDefault()

A function that prevents default on the current shortcut. The normal event.preventDefault() is also respected. Usage:

shortcut('meta a', input).bindsTo(uppercaseInput).preventDefault();

This usage would cause cmd + a to not hightlight the input, but rather call the uppercaseInput functions.

-stopPropagation()

A function that prevents bubbling on the current node to the document.body. The normal event.stopPropagation() is also respected. Usage:

shortcut('meta a', input).bindsTo(uppercaseInput).stopPropagation();
shortcut('meta a', document.body).bindsTo(grabText);

This usage would cause cmd + a call the uppercaseInput function, but not the grabText function.

-trigger()

A function to trigger the functions associated to a shortcut. Usage:

shortcut('meta a', input).bindsTo(
  e => console.log('triggerMe!')
).trigger();
// Triggers the bindsTo function and outputs:
// "triggerMe!"

-unbind()

A function used to remove bindings to keyboard shortcuts.

Usage:

shortcut('meta a', input).unbind();

Now when a user presses meta a in an input, it will not touch shortcut and run its normal native events.

-pause()

Pauses event dispatching for the associated shortcut.

Usage:

shortcut('meta a', input).pause();

When a user presss meta a in an input, it will not fire associated functions. Once -resume() is called they will fire.

-resume()

Resumes event dispatching for the associated shortcut.

Usage:

shortcut('meta a', input).pause();
// pressing meta a in an input does nothing
shortcut('meta a', input).resume();
// pressing meta a dispatches the functions again

When a user presss meta a in an input, it will not fire associated functions. Once -resume() is called they will fire.

License

Licensed under the MIT license. Copyright 2014-2015 Blaine Kasten