Skip to main content
Defined in: modules/input/src/keyboard-mouse/input.library.ts:21 Built-in input library.

Remarks

Listens to browser keydown/keyup (on window) and mousedown/ mouseup/mousemove/wheel/mouseenter/mouseleave/blur/ visibilitychange (on the client container) and exposes a per-frame snapshot of the current input state on Context.input. Mouse and drag positions are in game coordinates (mapped through Context.viewport, so they follow the design resolution, fit mode and window resizes). Client-only — __init throws if InitContext.container is missing.

Extends

  • Library

Constructors

Constructor

new InputLibrary(): InputLibrary
Defined in: modules/input/src/keyboard-mouse/input.library.ts:26

Returns

InputLibrary

Overrides

Library.constructor

Properties

key

readonly key: "input"
Defined in: modules/input/src/keyboard-mouse/input.library.ts:22 This library’s identity: its slot on Context, its registry key, and the identifier used to reference it in ordering relationships.

Overrides

Library.key

Accessors

relationships

Get Signature

get relationships(): LibraryRelationships
Defined in: packages/common/dist/index.d.ts:512 Internal
Returns
LibraryRelationships

Inherited from

Library.relationships

Methods

__clear()

__clear(): Promise<void>
Defined in: modules/input/src/keyboard-mouse/input.library.ts:42 Called once after the tick loop stops.

Returns

Promise<void>

Overrides

Library.__clear

__events()

__events(_ctx): Promise<void>
Defined in: packages/common/dist/index.d.ts:521 Called every tick, in run order, whether or not the tick loop is paused — unlike __run. Use this for event/message draining that must not be affected by pause (e.g. listening for the command that resumes the loop), not for gameplay simulation.

Parameters

_ctx
Context

Returns

Promise<void>

Inherited from

Library.__events

__init()

__init(ctx): Promise<void>
Defined in: modules/input/src/keyboard-mouse/input.library.ts:30 Called once, in dependency order, before the tick loop starts.

Parameters

ctx
InitContext

Returns

Promise<void>

Overrides

Library.__init

__run()

__run(): Promise<void>
Defined in: modules/input/src/keyboard-mouse/input.library.ts:37 Called every tick, in run order, while the tick loop is active and not paused.

Returns

Promise<void>

Overrides

Library.__run

expose()

expose(): InputContextApi
Defined in: modules/input/src/keyboard-mouse/input.library.ts:90 Returns this library’s public contribution to Context[this.key].

Returns

InputContextApi

Remarks

Return a plain object exposing only what game code should be able to reach — never this — so internal state and lifecycle hooks never leak onto Context. Libraries with nothing to expose (headless libraries) can leave this unimplemented; they simply won’t appear on Context.

Overrides

Library.expose

getDragState()

getDragState(): DragState
Defined in: modules/input/src/keyboard-mouse/input.library.ts:80

Returns

DragState

getMousePosition()

getMousePosition(): object
Defined in: modules/input/src/keyboard-mouse/input.library.ts:65

Returns

object
x
x: number
y
y: number

getMouseState()

getMouseState(): MouseState
Defined in: modules/input/src/keyboard-mouse/input.library.ts:70

Returns

MouseState

getPressedKeys()

getPressedKeys(): InputEnum[]
Defined in: modules/input/src/keyboard-mouse/input.library.ts:55

Returns

InputEnum[]

getWheelState()

getWheelState(): WheelState
Defined in: modules/input/src/keyboard-mouse/input.library.ts:85

Returns

WheelState

isDragging()

isDragging(button?): boolean
Defined in: modules/input/src/keyboard-mouse/input.library.ts:75

Parameters

button?
InputEnum

Returns

boolean

isKeyPressed()

isKeyPressed(key): boolean | undefined
Defined in: modules/input/src/keyboard-mouse/input.library.ts:50

Parameters

key
InputEnum

Returns

boolean | undefined true/false for a held/released key, undefined if the key has never been seen.

throwNotInitializedError()

protected throwNotInitializedError(): never
Defined in: packages/common/dist/index.d.ts:536

Returns

never

Inherited from

Library.throwNotInitializedError