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

kikey

v3.0.0

Published

An easy-to-use shortcut library.

Downloads

9

Readme

KikeyJS

KikeyJS is an easy-to-use shortcut library designed for simple event handling, supporting key sequences and shortcut recording. For an interactive introduction, visit the KikeyJS homepage: https://fobshippingpoint.github.io/kikey/.

Installation

KikeyJS provides UMD and ES Module formats.

Option 1: Use UMD

<!doctype html>
<html>
  <head>
    <script src="https://unpkg.com/kikey/dist/umd/kikey.min.js"></script>
  </head>
  <body>
    <script>
      const kikey = Kikey.createKikey();
    </script>
  </body>
</html>

Option 2: Use ES Module

<!doctype html>
<html>
  <body>
    <script type="module">
      import { createKikey } from "https://unpkg.com/kikey/dist/index.js";
      const kikey = createKikey();
    </script>
  </body>
</html>

Option 3: Via npm or jsr

npm install kikey
deno add @cclan/kikey

Usage

KikeyJS provides a very simple API for key binding, event handling, and recording:

// Key registration
const notice = () => alert("You pressed Ctrl+S");
kikey.on("C-s", notice);
// Unregistration
kikey.off(notice);

// Supports key sequences (chains)
kikey.on("A-l l f o r o n e", () => console.log("You pressed Alt+L → L → F → O → R → O → N → E"));

// Key sequence recording
kikey.startRecord();
// ...user presses key strokes...
// Stop recording and obtain the key binding sequence string for user customization
const sequence = kikey.stopRecord();

API

createKikey(targetElement)

  Creates a KikeyJS object that listens for keypress and keyup events on the specified targetElement. If no element is provided, it defaults to document.

on(sequence: string, callback: function)

  Binds a key sequence to a specified callback function. When the sequence is pressed in the correct order, the callback function is triggered.

  • sequence: The key sequence, which can be a single key, a combination of keys with modifiers like Ctrl, Shift, Alt, Meta concatenated with a dash (-), or a series of key bindings separated by whitespace.
  • callback: The callback function, which does not receive any arguments.

on(sequence: string, onComplete: function, onComboChange: function(level))

  • onComplete: Fired when the entire sequence is pressed correctly.
  • onComboChange (optional): A callback function for a series of key bindings. When a keyboard event is fired, onComboChange notifies the client of the current combo of the key sequence. combo=0 indicates that the combo has been broken.

off(callback: function)

  Remove binding for certain callback function.

once(sequence: string, onComplete: function, onComboChange: function(level))

  A one-time version of on.

updateSequence(newSequence: string, callback: function)

  Update key sequence by callback.

enable()

  Enable kikey.

disable()

  Disable kikey.

startRecord()

  Start shortcut recording.

stopRecord()

  Stop shortcut recording.

parseBinding(binding: string)

  Parse kikey-style key binding (e.g. C-a) and returns an object structured as follows:

{
    ctrlKey: true,
    shiftKey: false,
    altKey: false,
    metaKey: false,
    key: "a"
}

Suitable for the displaying the recorded shortcuts to users.

Modifiers

| Original Key | Notation | |--------------|----------| | Ctrl | C | | Shift | S | | Alt | A | | Meta | M |

KikeyJS supports modifiers. Use a dash (-) to concatenate strokes to form a single key binding. For example, C and S-o are both key bindings, as is C-S-A-M-p.

Special Keys

Keys with a character length greater than 1 are classified as Special Keys. This includes space and dash, which are used as key sequence delimiters.

  • space
  • dash
  • arrowleft
  • arrowright
  • arrowup
  • arrowdown
  • backspace
  • enter
  • escape
  • capslock
  • tab
  • home
  • pageup
  • pagedown
  • end
  • f1
  • f2
  • f3
  • f4
  • f5
  • f6
  • f7
  • f8
  • f9
  • f10
  • f11
  • f12