createInput()
Create the input for one surface, usually the canvas. Make one per surface and build everything else on it; dispose() removes every listener at once. DOM-only in practice, though the targets and clocks can be injected (see InputOptions) to drive it headlessly.
function createInput(el: EventTarget, opts?: InputOptions): Input;Defined in: engine/src/input/core.ts:236
Key events are read from window (they never target a canvas) and ignored while a text field
has focus. Held keys are released when the window loses focus or the page is hidden.
Parameters
| Parameter | Type | Description |
|---|---|---|
el | EventTarget | The surface. It receives pointer capture and, with lock(), pointer lock. |
opts? | InputOptions | - |
Returns
The input; pass it to recogniseGestures, makeActions, makeTouchControls, makeOrbitController or makeLookController.
Example
prepareSurface(canvas, { contextMenu: false });
const input = createInput(canvas, { loop });
const orbit = makeOrbitController(input, { distance: 200, pan: "secondary" });
// per frame:
input.update();
loop.setContinuous(input.active());