Skip to content

Documentation / @debuffjp/input / Input

Class: Input<A> ​

Defined in: input.ts:44

Action-based input across keyboard, pointer and gamepad.

ts
const input = new Input(game, {
  bindings: { left: ["ArrowLeft", "KeyA", "PadLeft"], jump: ["Space", "PadA", "Pointer"] },
});
if (input.pressed("jump")) jump();
const dx = input.axis("left", "right");

Edges are cleared automatically after each simulation step.

Type Parameters ​

A ​

A extends string

Constructors ​

Constructor ​

new Input<A>(host, options): Input<A>

Defined in: input.ts:51

Parameters ​

host ​

InputHost

options ​

InputOptions<A>

Returns ​

Input<A>

Properties ​

bindings ​

readonly bindings: Bindings<A>

Defined in: input.ts:48


keys ​

readonly keys: Keyboard

Defined in: input.ts:45


pads ​

readonly pads: Gamepads

Defined in: input.ts:47


pointer ​

readonly pointer: Pointer

Defined in: input.ts:46

Methods ​

axis() ​

axis(negative, positive): number

Defined in: input.ts:82

-1, 0 or 1 from two opposing actions, e.g. axis("left", "right").

Parameters ​

negative ​

A

positive ​

A

Returns ​

number


dispose() ​

dispose(): void

Defined in: input.ts:86

Returns ​

void


down() ​

down(action): boolean

Defined in: input.ts:65

Any binding for the action is held.

Parameters ​

action ​

A

Returns ​

boolean


pressed() ​

pressed(action): boolean

Defined in: input.ts:70

The action started this step.

Parameters ​

action ​

A

Returns ​

boolean


released() ​

released(action): boolean

Defined in: input.ts:75

The action ended this step.

Parameters ​

action ​

A

Returns ​

boolean