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

keyboard-cjs

v0.0.4

Published

High quality keybinding library

Downloads

10

Readme

Keyboard

An object that gives the keyboard a first class identity, normalizes keyboard events across browsers, and allows binding to multiple keys.

This is a CommonJS version of the Brandon Benvie's Keyboard.

Example Usage

// create a new Keyboard object that is scoped to a specific DOM element or the window
var kb = new Keyboard(window);

// when both ctrl+a are pressed together
kb.on('ctrl+a', 'activate', function(e){ /***/ });

// when a, then be, then c are pressed in sequence and released
kb.on('a->b->c', 'release', function(e){ /***/ });

// when any key is first pressed (including modifiers such as shift/control/etc.)
kb.on('*', 'activate', function(e){ /***/ })

// when any key is activated, pressed, repeats, released
kb.on('*', function(e){
  console.log(e.action); // one of ['activate', 'repeat', 'release', 'press']
});

API

  • new Keyboard(view)
    view: a Window, Document, or Element which will be listened to

  • keyboard.on(keyCombo, [filter], callback)
    keyCombo: a string that can be any key name or a combination of key names separated by '+' or '->'. The '+' combinator requires the keys be held together, '->' requires they be pressed in a specific sequence.

    filter: optional and must be one

    • activate: when a key is first depressed
    • repeat: when a keydown due to the key being held down
    • release: fires on keyup
    • press: fires on keypress

    callback: called with the keyboardEvent object if the keyCombo was a single key, or an array of keyboardEvent objects if the keyCombo was a combinator.

  • keyboardEvent.action
    What type of action the event originated from. Same as the above filter types.

CommonJS (aka browserify and requirejs)

Installation:

npm install keyboard-cjs --save

Usage as a Browserify's module:


var Keyboard = require('keyboard-cjs');

var kb = new Keyboard(window);

Usage as a RequireJS module:

require(['Keyboard.js'], function(Keyboard) {
    var kb = new Keyboard(window);
});

Support and Contribution

This project "keyboard-cjs" was forked from the Brandon Benvie's project "Keyboard" on Feb 24, 2014 by Ilya Lakhin by the terms of MIT license, since the author has abandoned original project, and doesn't manage neither Issues, nor email requests.

The motivation of this fork was support of CommonJS interface for Browserify and RequireJS. But as far Brandon is away(I hope he is ok) I will maintain the project: fix bugs, implement new features by request etc. So please feel free to contribute in this project, or ask support in any form convenient for you.

When Brendon return back, I believe we will push all the changes made in the "keyboard-cjs" to the original project back.

  • Issue tracker.
  • My email and jabber: eliah.lakhin [at] gmail.com.
  • My skype: "eliah.lakhin".