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 ​
new InputCapture(options?): InputCapture;Defined in: src/input/InputCapture.ts:84
Parameters ​
| Parameter | Type |
|---|---|
options | CaptureOptions |
Returns ​
InputCapture
Properties ​
result ​
readonly result: Promise<string | null>;Defined in: src/input/InputCapture.ts:75
Accessors ​
open ​
Get Signature ​
get open(): boolean;Defined in: src/input/InputCapture.ts:117
Returns ​
boolean
Methods ​
cancel() ​
cancel(): void;Defined in: src/input/InputCapture.ts:113
Stops waiting; the result is null.
Returns ​
void
poll() ​
poll(): void;Defined in: src/input/InputCapture.ts:101
Reads the gamepads once; call every frame while the capture is open.
Returns ​
void