Skip to content

1681-engine / index / InputCapture

Class: InputCapture ​

Defined in: src/input/InputCapture.ts:74

Waits for the next input the player gives, for a settings screen's "press a key for Jump": the next key (its KeyboardEvent.code), gamepad button or stick half pushed past a threshold, as a binding string Actions and Keymap take. Inputs already held when the capture began do not count until let go, so the press that opened the capture (Enter, the pad's A) does not bind itself.

Call poll() once a frame for the gamepad (the browser has no gamepad events worth trusting); keys are heard as they come. The promise resolves to the binding, or null when cancelled (Escape, or cancel()).

Constructors ​

Constructor ​

ts
new InputCapture(options?): InputCapture;

Defined in: src/input/InputCapture.ts:84

Parameters ​

ParameterType
optionsCaptureOptions

Returns ​

InputCapture

Properties ​

result ​

ts
readonly result: Promise<string | null>;

Defined in: src/input/InputCapture.ts:75

Accessors ​

open ​

Get Signature ​

ts
get open(): boolean;

Defined in: src/input/InputCapture.ts:117

Returns ​

boolean

Methods ​

cancel() ​

ts
cancel(): void;

Defined in: src/input/InputCapture.ts:113

Stops waiting; the result is null.

Returns ​

void


poll() ​

ts
poll(): void;

Defined in: src/input/InputCapture.ts:101

Reads the gamepads once; call every frame while the capture is open.

Returns ​

void

Released under the MIT License.