Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Input

Input related methods and properties.

Note: Setting event handlers to the primary input will overwrite it. To preserve the primary input, use Input.preserveApplicationInput.

Primary input per platform:

  • Web: mouse click
  • Mobile: tapping on screen
  • VR (no controller): tapping on screen or on physical viewer button

Index

Type Aliases

KeyCode: "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "f1" | "f2" | "f3" | "f4" | "f5" | "f6" | "f7" | "f8" | "f9" | "f11" | "f12" | "zero" | "one" | "two" | "three" | "four" | "five" | "six" | "seven" | "eight" | "nine" | "num_lock" | "num_pad_zero" | "num_pad_one" | "num_pad_two" | "num_pad_three" | "num_pad_four" | "num_pad_five" | "num_pad_six" | "num_pad_seven" | "num_pad_eight" | "num_pad_nine" | "num_pad_plus" | "num_pad_minus" | "num_pad_multiply" | "num_pad_period" | "num_pad_division" | "plus" | "minus" | "space" | "backspace" | "capslock" | "tab" | "enter" | "esc" | "delete" | "insert" | "left" | "right" | "up" | "down" | "primary" | "left_mouse_button" | "right_mouse_button" | "middle_mouse_button"

Provides a set of key codes that are mapped directly to physical keyboard and mouse keys.

Variables

clickDirection: Vector3

Returns Vector3 click direction originating from the Camera.

returns

click direction.

See Camera

preserveApplicationInput: boolean

If true, preserves primary controls (such as turning the Camera and selecting items) when a custom primary input was defined.

reticleEnabled: boolean

Toggles animated reticle display.

If true:

  • On mobile: Displays a reticle at the screen center
  • On desktop: Displays a reticle underneath the current mouse position

Note: Can be used with Camera.mouseLocked to create mouse-based camera control on desktop.

Functions

  • bindClickToKey(keyCode: KeyCode): void
  • Binds the left mouse button click to the specified Input.KeyCode.

    When the key is pressed, a click from the current mouse position is send.

    Note: No click is send on mobile and VR devices.

    Parameters

    Returns void

  • onKeyDown(handler: (() => void), keyCode: KeyCode): void
  • Triggers an event whenever the specified Input.KeyCode is pressed down.

    Note: Only one onKeyDown handler can be defined for a key at any time.

    Parameters

    • handler: (() => void)

      function to call. Pass null to remove the handler.

        • (): void
        • Returns void

    • keyCode: KeyCode

      key to press.

    Returns void

  • onKeyPressed(handler: (() => void), keyCode: KeyCode): void
  • Triggers every frame while specified Input.KeyCode is pressed.

    Note: Only one onKeyPressed handler can be defined for a key at any time.

    Parameters

    • handler: (() => void)

      function to call. Pass null to remove the handler.

        • (): void
        • Returns void

    • keyCode: KeyCode

      key to press.

    Returns void

  • onKeyUp(handler: (() => void), keyCode: KeyCode): void
  • Triggers an event whenever the specified Input.KeyCode is released.

    Note: Only one onKeyUp handler can be defined for a key at any time.

    Parameters

    • handler: (() => void)

      function to call. Pass null to remove the handler.

        • (): void
        • Returns void

    • keyCode: KeyCode

      key to press.

    Returns void