setUpKeyboardEvents

View sourcesetUpKeyboardEvents(world: World, target: HTMLElement): void

Forwards browser keyboard events from an HTMLElement to the typed Events resources in a World. The keydown listener queues a KeyDown value, and the keyup listener queues a KeyUp value.

The matching Events<KeyUp> and Events<KeyDown> resources must already be registered in world before this helper is called. Calling it again adds another pair of listeners; it does not return a cleanup function or remove listeners automatically.

Examples

setUpKeyboardEvents(world, canvas)

Parameters

NameDescriptionDefault
world

World containing the keyboard event resources.

—
target

Element that receives keyboard events.

—