Skip to content

Documentation / @debuffjp/input

@debuffjp/input ​

Action-based input across keyboard, mouse/touch/pen (Pointer Events) and gamepads (standard mapping). No dependencies.

ts
import { Input } from "@debuffjp/input";

const input = new Input(game, {
  bindings: {
    left: ["ArrowLeft", "KeyA", "PadLeft", "PadStickLeft"],
    right: ["ArrowRight", "KeyD", "PadRight", "PadStickRight"],
    jump: ["Space", "PadA", "Pointer"],
  },
});

// inside Scene.update
const dx = input.axis("left", "right");
if (input.pressed("jump")) jump();

Edges clear automatically after each simulation step, so a tap shorter than a frame is never missed.

Binding names ​

SourceNames
KeyboardKeyboardEvent.code: Space, KeyZ, ArrowUp, …
PointerPointer (primary mouse button, touch or pen)
GamepadPadA PadB PadX PadY PadL1 PadR1 PadL2 PadR2 PadSelect PadStart PadL3 PadR3 PadUp PadDown PadLeft PadRight
Left stickPadStickUp PadStickDown PadStickLeft PadStickRight

API ​

  • input.down(action), input.pressed(action), input.released(action), input.axis(neg, pos)
  • input.pointer: x, y (logical), down, pressed, released, touches
  • input.keys: down(code), pressed(code), released(code)
  • input.pads: stickX, stickY, connected, deadzone
  • Programmatic control for tests and on-screen buttons: keys.press/release, pointer.press/move/release

Classes ​

Interfaces ​

Type Aliases ​

Variables ​