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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@benjos/spices

v2.0.1

Published

Collection of TypeScript common constant files for personal projects

Readme

@benjos/spices

Collection of TypeScript common constant files for personal projects.

ESM-only. Ships compiled JavaScript with type declarations — works in plain JS projects too, TypeScript is optional.

Installation

npm install @benjos/spices

Usage

import { DomEvent, KeyboardKey, KeyboardCode } from '@benjos/spices';

window.addEventListener(DomEvent.KEY_DOWN, (event) => {
    if (event.key === KeyboardKey.ESCAPE) {
        closeModal();
    }
    // Physical key position, independent of keyboard layout:
    if (event.code === KeyboardCode.KEY_W) {
        moveForward();
    }
});

Each constant is also exported as the string-literal union of its values:

import type { DomEvent, KeyboardKey, KeyboardCode } from '@benjos/spices';

function on(event: DomEvent, handler: EventListener): void { /* ... */ }
const shortcut: KeyboardKey = 'Escape';

Available Constants

DomEvent

DOM event names: mouse, pointer, touch, keyboard, focus, form, document, window, clipboard, drag & drop, media, animation, and transition events.

KeyboardKey

Values of KeyboardEvent.key (layout-dependent, US-QWERTY for punctuation):

  • Letters: A–Z hold the unshifted value (KeyboardKey.A === 'a'); UPPER_A–UPPER_Z hold the Shift/CapsLock value ('A')
  • Digits: DIGIT_0–DIGIT_9, and their shifted symbols (EXCLAMATION_MARK, AT, ...)
  • Navigation: ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END, ...
  • Special: ENTER, ESCAPE, TAB, BACKSPACE, SPACE, ...
  • Modifiers: SHIFT, CONTROL, ALT, META
  • Function keys: F1–F12

KeyboardCode

Values of KeyboardEvent.code — physical key positions, layout-independent: KEY_A–KEY_Z, DIGIT_0–DIGIT_9, NUMPAD_0–NUMPAD_9 and numpad operators, left/right modifier variants (SHIFT_LEFT, META_RIGHT, ...), F1–F12, punctuation.

Migrating from 1.x

| 1.x | 2.0 | | --- | --- | | KeyboardConstant.KEYS.* | KeyboardKey.* | | KeyboardConstant.CODES.* | KeyboardCode.* | | KeyboardConstant.KEYS.A ('A') | KeyboardKey.UPPER_A | | KeyboardConstant.KEYS.LOWER_A ('a') | KeyboardKey.A | | KeyboardConstant.KEYS.QUOTE_2 | KeyboardKey.DOUBLE_QUOTE | | KeyboardConstant.KEYS.OPEN_BRACE / CLOSE_BRACE | KeyboardKey.BRACE_LEFT / BRACE_RIGHT | | KeyboardConstant.KEYS.EXCLAMATION | KeyboardKey.EXCLAMATION_MARK | | KeyboardConstant.KEYS.SHARP | KeyboardKey.HASH | | DomEvent.MOUSE_WHEEL | DomEvent.WHEEL | | DomEvent.KEY_PRESS (deprecated event) | removed — use DomEvent.KEY_DOWN | | DomEvent.UNLOAD (deprecated event) | removed — use DomEvent.PAGE_HIDE or DomEvent.VISIBILITY_CHANGE | | DomEventType | removed — use the DomEvent type (same string union) | | KeyboardConstantType | removed — it was the union of the KEYS/CODES object shapes, not of key strings; use the KeyboardKey / KeyboardCode types instead |

License

ISC