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

secret-sequence-core

v2.0.1

Published

Headless stratagem-style input engine — detect directional sequences, key combos, and multi-pattern inputs

Downloads

14

Readme

Secret Sequence Core

en es

GitHub stars GitHub forks GitHub issues GitHub Sponsors

TypeScript

Framework-agnostic input engine for detecting directional sequences, key combinations, and touch gestures — written in pure TypeScript with zero runtime dependencies.

This package is the core engine of the Secret Sequence monorepo.
It contains all input detection logic and can run in any JavaScript or TypeScript environment.


Installation

npm install secret-sequence-core

Quick Start

Stratagem-Style Input

import { SecretSequenceEngine } from "secret-sequence-core"

const engine = new SecretSequenceEngine({
  sequences: [
    {
      id: "orbitalStrike",
      sequence: ["right", "right", "up"],
      onSuccess: () => deployStrike(),
    },
  ],
  timeout: 2000,
  onProgress: (id, progress) => {
    console.log(`${id}: ${progress} steps completed`)
  },
})

engine.start()

Konami Code

const engine = new SecretSequenceEngine({
  sequences: [
    {
      id: "konami",
      sequence: ["up", "up", "down", "down", "left", "right", "left", "right"],
      onSuccess: () => alert("🎉 Konami Code activated!"),
    },
  ],
  timeout: 3000,
})

engine.start()

Key Combo Shortcut

const engine = new SecretSequenceEngine({
  sequences: [
    {
      id: "shortcut",
      sequence: [{ key: "k", ctrl: true }],
      onSuccess: () => console.log("Shortcut triggered"),
    },
  ],
})

engine.start()

Touch Gesture Support

Swipe gestures on touch devices are automatically mapped to directional steps.

const engine = new SecretSequenceEngine({
  sequences: [
    {
      id: "konami",
      sequence: ["up", "up", "down", "down", "left", "right", "left", "right"],
      onSuccess: () => alert("🎉 Konami Code activated!"),
    },
  ],
  enableTouch: true, // enabled by default
  touchOptions: {
    minDistance: 30,  // minimum swipe distance (px)
    maxTime: 300,     // maximum swipe duration (ms)
    threshold: 1.5,   // dominant axis ratio to reject diagonals
  },
})

engine.start()

Multiple Sequences

const engine = new SecretSequenceEngine({
  sequences: [
    {
      id: "konami",
      sequence: ["up", "up", "down", "down", "left", "right", "left", "right"],
      onSuccess: () => console.log("Konami!"),
    },
    {
      id: "unlock",
      sequence: [
        { key: "k", ctrl: true },
        { key: "u", ctrl: true },
      ],
      onSuccess: () => console.log("Ctrl+K → Ctrl+U unlocked!"),
    },
  ],
  onProgress: (id, progress) => {
    console.log(`Sequence "${id}" progress: ${progress}`)
  },
})

engine.start()

API

new SecretSequenceEngine(options)

Creates a new engine instance.


Options

| Option | Type | Default | Description | | -------------- | ----------------------------------------------------- | ------- | ------------------------------------------------------ | | sequences | SecretSequenceConfig[] | — | Array of sequences to detect simultaneously | | timeout | number | 2000 | Milliseconds of inactivity before resetting progress | | enabled | boolean | true | Globally enable or disable detection | | enableTouch | boolean | true | Enable swipe gesture detection | | ignoreInputs | boolean | true | Ignore key events when focus is on input-like elements | | touchOptions | TouchConfig | — | Advanced touch configuration | | onProgress | (id: string \| undefined, progress: number) => void | — | Fired on each successful step |


Methods

| Method | Returns | Description | | ------------------ | ------------------------ | ---------------------------------------------------- | | start() | void | Attach event listeners | | stop() | void | Remove event listeners | | destroy() | void | Stop detection and reset progress | | reset() | void | Reset all sequence progress | | getProgressMap() | Record<string, number> | Get current progress state | | setOptions(opts) | void | Update configuration at runtime (restarts if active) |


Configuration Types

SecretSequenceConfig

| Property | Type | Description | | ----------- | --------------------- | ------------------------------------------- | | id | string (optional) | Unique identifier (defaults to array index) | | sequence | SequenceStep[] | Ordered steps to detect | | onSuccess | () => void | Fired when the sequence completes |


Core Types

type Direction = "up" | "down" | "left" | "right"

type KeyCombo = {
  key: string
  ctrl?: boolean
  shift?: boolean
  alt?: boolean
  meta?: boolean
}

type SequenceStep = Direction | KeyCombo

A SequenceStep can be:

  • A Direction string (mapped to arrow keys)
  • A KeyCombo object with optional modifier keys

TouchConfig

| Property | Type | Default | Description | | ------------- | -------- | ------- | ---------------------------------------------- | | minDistance | number | 30 | Minimum swipe distance (px) | | maxTime | number | 300 | Maximum swipe duration (ms) | | threshold | number | 1.5 | Axis dominance ratio to reject diagonal swipes |


SSR Compatibility

This engine is safe to use in SSR environments such as Next.js or Remix.

It guards against accessing window during server rendering and only attaches event listeners in the browser.


License

MIT © Diego Alonso