Options
All
  • Public
  • Public/Protected
  • All
Menu

Store input made on a canvas: mouse position, key pressed and touches states.

Hierarchy

  • InputManager

Index

Properties

MOUSE_BACK_BUTTON: number = 3
MOUSE_FORWARD_BUTTON: number = 4
MOUSE_LEFT_BUTTON: number = 0
MOUSE_MIDDLE_BUTTON: number = 2
MOUSE_RIGHT_BUTTON: number = 1
MOUSE_TOUCH_ID: number = 1

Methods

  • anyKeyPressed(): boolean
  • anyKeyReleased(): boolean
  • clearAllPressedKeys(): void
  • getAllTouchIdentifiers(): number[]
  • getCursorX(): number
  • Get the cursor X position. The cursor is moved by mouse and touch events.

    Returns number

    the cursor X position, relative to the game view.

  • getCursorY(): number
  • Get the cursor Y position. The cursor is moved by mouse and touch events.

    Returns number

    the cursor Y position, relative to the game view.

  • getLastPressedKey(): number
  • Return the location-aware code of the last key that was pressed.

    Returns number

    The location-aware code of the last key pressed.

  • getMouseWheelDelta(): number
  • getMouseX(): number
  • getMouseY(): number
  • getStartedTouchIdentifiers(): number[]
  • getTouchX(publicIdentifier: number): number
  • Get a touch X position.

    Parameters

    • publicIdentifier: number

    Returns number

    the touch X position, relative to the game view.

  • getTouchY(publicIdentifier: number): number
  • Get a touch Y position.

    Parameters

    • publicIdentifier: number

    Returns number

    the touch Y position, relative to the game view.

  • hasTouchEnded(publicIdentifier: number): boolean
  • isKeyPressed(locationAwareKeyCode: number): boolean
  • Return true if the key corresponding to the location-aware keyCode is pressed.

    Parameters

    • locationAwareKeyCode: number

      The location-aware key code to be tested.

    Returns boolean

  • isMouseButtonPressed(buttonCode: number): boolean
  • Return true if the mouse button corresponding to buttonCode is pressed.

    Parameters

    • buttonCode: number

      The mouse button code (0: Left button, 1: Right button).

    Returns boolean

  • isMouseButtonReleased(buttonCode: number): boolean
  • Return true if the mouse button corresponding to buttonCode was just released.

    Parameters

    • buttonCode: number

      The mouse button code (0: Left button, 1: Right button).

    Returns boolean

  • isMouseInsideCanvas(): boolean
  • isScrollingDown(): boolean
  • isScrollingUp(): boolean
  • isSimulatingMouseWithTouch(): boolean
  • onFrameEnded(): void
  • Notify the input manager that the frame ended, so anything that last only for one frame (started/ended touches) should be reset.

    This method should be called in the game loop (see gdjs.RuntimeGame.startGameLoop). You don't need to call it otherwise.

    Returns void

  • onKeyPressed(keyCode: number, location?: number): void
  • Should be called whenever a key is pressed. The location corresponds to KeyboardEvent.location, which should be 0 for standard keys, 1 for left keys, 2 for right keys, and 3 for numpad keys.

    Parameters

    • keyCode: number

      The raw key code associated to the key press.

    • Optional location: number

      The location of the event.

    Returns void

  • onKeyReleased(keyCode: number, location?: number): void
  • Should be called whenever a key is released. The location corresponds to KeyboardEvent.location, which should be 0 for standard keys, 1 for left keys, 2 for right keys, and 3 for numpad keys.

    Parameters

    • keyCode: number

      The raw key code associated to the key release.

    • Optional location: number

      The location of the event.

    Returns void

  • onMouseButtonPressed(buttonCode: number): void
  • Should be called whenever a mouse button is pressed.

    Parameters

    • buttonCode: number

      The mouse button code associated to the event. See InputManager.MOUSE_LEFT_BUTTON, InputManager.MOUSE_RIGHT_BUTTON, InputManager.MOUSE_MIDDLE_BUTTON

    Returns void

  • onMouseButtonReleased(buttonCode: number): void
  • Should be called whenever a mouse button is released.

    Parameters

    • buttonCode: number

      The mouse button code associated to the event. (see onMouseButtonPressed)

    Returns void

  • onMouseEnter(): void
  • onMouseLeave(): void
  • onMouseMove(x: number, y: number): void
  • Should be called when the mouse is moved.

    Please note that the coordinates must be expressed relative to the view position.

    Parameters

    • x: number

      The mouse new X position

    • y: number

      The mouse new Y position

    Returns void

  • onMouseWheel(wheelDelta: number): void
  • onTouchCancel(rawIdentifier: number): void
  • onTouchEnd(rawIdentifier: number): void
  • onTouchMove(rawIdentifier: number, x: number, y: number): void
  • onTouchStart(rawIdentifier: number, x: number, y: number): void
  • popEndedTouch(): undefined | number
  • popStartedTouch(): undefined | number
  • touchSimulateMouse(enable: boolean): void
  • Set if touch events should simulate mouse events.

    If true, any touch will move the mouse position and set mouse buttons as pressed/released.

    Parameters

    • enable: boolean

      true to simulate mouse events, false to disable it.

    Returns void

  • wasKeyReleased(locationAwareKeyCode: number): boolean
  • Return true if the key corresponding to the location-aware keyCode was released during the last frame.

    Parameters

    • locationAwareKeyCode: number

      The location-aware key code to be tested.

    Returns boolean

  • getPublicTouchIdentifier(rawIdentifier: number): number
  • Add 2 to the identifier to avoid identifiers taking the GDevelop default variable value which is 0 and reserve 1 for the mouse.

    Parameters

    • rawIdentifier: number

      The identifier given by the browser.

    Returns number

    The identifier used in events.

Constructors

Generated using TypeDoc