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

dolmen-keys

v0.0.5

Published

Dolmen keyboard shortcuts

Downloads

50

Readme

dolmen-keys

This package contains a number of useful modules for keyboard handling in games and 3D applications using Solid.js.

Typically in a game, keys are used as real-time control signals. A particular movement or action, such as moving forward or turning left, will be performed continuously for as long as a key is held down. Moreover, these actions are often assigned to key combinations, such as "shift+left to strafe left".

These methods require a KeysManagerContext:

<KeysManagerContext.Provider value={new KeysManager()}>
  {...}
</KeysManagerContext.Provider>

The KeysManager.activeKeys property returns an object that has a boolean flag for each keyboard key that is currently held down. This is a reactive store.

createActiveKeys

The createActiveKeys hook allows key combinations to be mapped to a set of boolean signals. It includes logic to normalize the modifier keys - so you can listen for shift, left-shift, right-shift and so on.

const cameraControls = createActiveKeys({
  strafeLeft: 'shift+left',
  strafeRight: 'shift+right',
  rotateLeft: 'left',
  rotateRight: 'right',
  moveForward: 'up',
  moveBack: 'down',
});

The return result is a reactive store which has a property for each of the named signals.

function animate() {
  if (keys.strafeLeft) {
    // update position
  }

  if (keys.rotateLeft) {
    // etc.
  }
}

There is an exclusion algorithm which prevents multiple signals using the same base key from being triggered simultaneously. The 'base key' is the rightmost key in the key combo string, so for example in the combo 'shift-a' the base key is 'a'. If multiple signals are defined using the same base key, only one of those signals can be active at a time.

Under the exclusion rule, key combos defined earlier in the map take precedence over those defined later. So in the above example, both 'strafeLeft' and 'rotateLeft' have the same base key, 'left'. Pressing 'shift+left' will activate the 'strafeLeft' signal only. Pressing 'left' without shift will activate only the 'rotateLeft' signal. This works regardless of the order in which the keys are pressed, so if 'shift' is pressed while already holding down 'left', the activated signal will change from 'rotateLeft' to 'strafeLeft'.

Because of this, you will generally want to put the more complex key combinations first, so that they take precedence over combinations with fewer keys.

createShortcuts

The createShortcuts hook allows you to listen for keypresses instead of held keys.

These functions can be used together in the following way:

createShortcuts({
  'ctrl+z': onUndo,
  'meta+z': onUndo,
  esc: onCancelDrag,
});

// Now use cameraControls.strafeLeft, etc.;