Documentation / @debuffjp/input / Input
Class: Input<A>
Defined in: input.ts:44
Action-based input across keyboard, pointer and gamepad.
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
options
InputOptions<A>
Returns
Input<A>
Properties
bindings
readonlybindings:Bindings<A>
Defined in: input.ts:48
keys
readonlykeys:Keyboard
Defined in: input.ts:45
pads
readonlypads:Gamepads
Defined in: input.ts:47
pointer
readonlypointer: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