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

@rbxts/mechanism

v1.1.0

Published

An elegant composable input library for Roblox

Downloads

780

Readme

Mechanism

An elegant composable input library for Roblox

Examples

Creating an InputManager

An InputManager is a context to bind actions to. It is disposable and unbinds all actions when destroyed. The constructor takes a useAllGamepads parameter, which when false only uses Gamepad1 and not any other gamepad input type.

import { InputManager, StandardActionBuilder } from "@rbxts/mechanism";

const input = new InputManager;
const action = new StandardActionBuilder().setID("testID");
input.bind(action);
input.unbind(action);
input.unbind("testID");

StandardAction

import { InputManager, StandardActionBuilder } from "@rbxts/mechanism";

const input = new InputManager;
const crouchAction = new StandardActionBuilder("C", "LeftCtrl")
  .setProcessed(false) // only activates when gameProcessedEvent is false, false by default
  .setCooldown(0.25); // can only be activated every 0.25 seconds
  .setInputQueueing(false); // if this were true, it would queue every input made during a cooldown to be activated after the cooldown is over

crouchAction.activated.Connect(() => print("crouched"));
crouchAction.deactivated.Connect(() => print("stood"));

input.bind(crouchAction);

AxisAction

import { InputManager, AxisActionBuilder } from "@rbxts/mechanism";

const input = new InputManager;
const scrollAction = new AxisActionBuilder("MouseWheel");

scrollAction.updated.Connect(() => print("scroll position:", scrollAction.position.Z));

input.bind(scrollAction);

RepeatAction

A RepeatAction is an input that must be repeated multiple times to activate.

import { InputManager, RepeatActionBuilder } from "@rbxts/mechanism";

const input = new InputManager;
const sprintAction = new RepeatActionBuilder("W")
  .setRepeats(2) // takes 2 presses to activate
  .setTiming(0.3); // each press must be within 0.3 seconds of each other, 0 by default (which is infinite time between presses)

sprintAction.activated.Connect(() => print("sprinting"));
sprintAction.deactivated.Connect(() => print("walking"));

input.bind(sprintAction);

CompositeAction

A CompositeAction is an action composed of multiple inputs that must all be simultaneously pressed to activate the action. The action is deactivated when one of the inputs is released.

import { InputManager, CompositeActionBuilder } from "@rbxts/mechanism";

const input = new InputManager;
const toggleAction = new CompositeActionBuilder("LeftCtrl", "LeftAlt", "M")
  .setTiming(0.5); // each press must be within 0.5 seconds of each other

toggleAction.activated.Connect(() => print("toggled"));

input.bind(toggleAction);

SequentialAction

A SequentialAction is an action composed of multiple inputs that must all be pressed in order to activate the action. The action is deactivated when one of the last input in the sequence is released.

import { InputManager, SequentialActionBuilder } from "@rbxts/mechanism";

const input = new InputManager;
const menAction = new SequentialActionBuilder("M", "E", "N")
  .setTiming(0.5); // each press must be within 0.5 seconds of each other

menAction.activated.Connect(() => print("typed 'men' quickly"));

input.bind(menAction);

UniqueAction

A UniqueAction is an action composed of multiple child actions and is only active when exactly one of the child actions is active.

import { InputManager, UniqueActionBuilder } from "@rbxts/mechanism";

const input = new InputManager;
const cOrVAction = new UniqueActionBuilder(
  new StandardActionBuilder("C"),
  new StandardActionBuilder("V")
);

cOrVAction.activated.Connect(() => print("pressed C or V exclusively"));

input.bind(cOrVAction);

DynamicAction

A DynamicAction is an action containing one interchangable action.

import { InputManager, DynamicAction } from "@rbxts/mechanism";

const input = new InputManager;
const crouchAction = new DynamicAction(new StandardActionBuilder("C")); // default bind

keybinds.changed.Connect(keybinds => 
  crouchAction.updateAction(new StandardActionBuilder(keybinds.crouch)) // update bind based on data
);

crouchAction.activated.Connect(() => print("crouched"));
crouchAction.deactivated.Connect(() => print("stood"));

input.bind(crouchAction);