The input system is responsible for handling all input events like pointer events (mouse, touch, xr controllers) and keyboard events.

Implements

Accessors

  • get click(): boolean

    Is the primary pointer double clicked (usually the left button). This is equivalent to input.mouseDoubleClick

    Returns boolean

  • get doubleClick(): boolean

    Was a double click detected for the primary pointer?

    Returns boolean

  • get mouseClick(): boolean

    Is the primary pointer clicked (usually the left button). This is equivalent to input.click

    Returns boolean

  • get mouseDoubleClick(): boolean

    Was a double click detected for the primary pointer? This is equivalent to input.doubleClick

    Returns boolean

  • get mouseDown(): boolean

    Returns boolean

  • get mousePressed(): boolean

    Returns boolean

  • get mouseUp(): boolean

    Returns boolean

  • get mouseWheelChanged(): boolean

    Returns boolean

Methods

  • Adds an event listener for the specified event type. The callback will be called when the event is triggered.

    Parameters

    • type: PointerEventNames

      The event type to listen for

    • callback: PointerEventListener

      The callback to call when the event is triggered

    • Optionaloptions: EventListenerOptions

      The options for adding the event listener.

    Returns any

    input.addEventListener("pointerdown", (evt) => { 
    console.log("Pointer down", evt.pointerId, evt.pointerType);
    });

    By using a higher value for the queue the listener will be called after other listeners (default queue is 0).

    input.addEventListener("pointerdown", (evt) => {
    console.log("Pointer down", evt.pointerId, evt.pointerType);
    }, { queue: 10 });
    input.addEventListener("pointerdown", (evt) => {
    console.log("Pointer down", evt.pointerId, evt.pointerType);
    }, { once: true });
  • Adds an event listener for the specified event type. The callback will be called when the event is triggered.

    Parameters

    • type: KeyboardEventNames

      The event type to listen for

    • callback: KeyboardEventListener

      The callback to call when the event is triggered

    • Optionaloptions: EventListenerOptions

      The options for adding the event listener.

    Returns any

    input.addEventListener("pointerdown", (evt) => { 
    console.log("Pointer down", evt.pointerId, evt.pointerType);
    });

    By using a higher value for the queue the listener will be called after other listeners (default queue is 0).

    input.addEventListener("pointerdown", (evt) => {
    console.log("Pointer down", evt.pointerId, evt.pointerType);
    }, { queue: 10 });
    input.addEventListener("pointerdown", (evt) => {
    console.log("Pointer down", evt.pointerId, evt.pointerType);
    }, { once: true });
  • Returns void

  • Returns void

  • Parameters

    • OptionalpointerType: string | string[] | PointerType[]

    Returns Generator<number>

  • the first button that was down and is currently pressed

    Parameters

    • pointerId: number

    Returns undefined | number

  • Parameters

    • i: number

    Returns boolean

  • Check if a pointer id is currently used.

    Parameters

    • pointerId: number

    Returns boolean

  • Parameters

    • i: number

    Returns boolean

  • Get a key (if any) that was just pressed this frame (this is only true for the frame it was pressed down)

    Returns null | string

  • Get true or false if the given key was pressed this frame

    Parameters

    • key: KeyCode | {} & string

    Returns boolean

  • Get a key (if any) that is currently being pressed (held down)

    Returns null | string

  • Get true or false if the given key is pressed

    Parameters

    • key: KeyCode | {} & string

    Returns boolean

  • Get a key (if any) that was released in this frame

    Returns null | string

  • Get true or false if the given key was released this frame

    Parameters

    • key: KeyCode | {} & string

    Returns boolean

  • the last (most recent) button that was down and is currently pressed

    Parameters

    • pointerId: number

    Returns undefined | number

  • Parameters

    • i: number = 0

    Returns boolean

  • Parameters

    • i: number = 0

    Returns number

  • Parameters

    • i: number

    Returns boolean

  • Parameters

    • i: number

    Returns boolean

  • Parameters

    • i: number

    Returns boolean

  • Parameters

    • i: number

    Returns number

  • Parameters

    • i: number

    Returns undefined | Event

  • Parameters

    • i: number

    Returns boolean

  • Gets the position of the given pointer index in pixel

    Parameters

    • i: number

      The pointer index

    Returns null | Vector2

    The position of the pointer in pixel

  • Parameters

    • i: number

    Returns null | Vector2

  • Parameters

    • i: number

    Returns null | Vector2

  • Parameters

    • i: number

    Returns boolean

  • how many pointers are currently pressed

    Returns number

  • Parameters

    • i: number

    Returns boolean

  • Parameters

    • i: number

    Returns number

  • Returns number

  • Parameters

    • keyCode: KeyCode | {} & string

    Returns boolean

  • Parameters

    • keyCode: KeyCode | {} & string

    Returns boolean

  • Parameters

    • keyCode: KeyCode | {} & string

    Returns boolean

  • Removes the event listener from the specified event type. If no queue is specified the listener will be removed from all queues.

    Parameters

    • type: PointerEventNames

      The event type to remove the listener from

    • callback: PointerEventListener

      The callback to remove

    • Optionaloptions: EventListenerOptions

      The options for removing the event listener

    Returns any

  • Removes the event listener from the specified event type. If no queue is specified the listener will be removed from all queues.

    Parameters

    • type: KeyboardEventNames

      The event type to remove the listener from

    • callback: KeyboardEventListener

      The callback to remove

    • Optionaloptions: EventListenerOptions

      The options for removing the event listener

    Returns any

  • Set a custom cursor. This will set the cursor type until unsetCursor is called

    Parameters

    Returns void

  • Returns void

    use unsetCursor()

  • Returns void

    use setCursor("pointer")

  • Returns void

  • Unset a custom cursor. This will set the cursor type to the previous type or default

    Parameters

    Returns void