# Class: Input

## Phaser. Input

Phaser.Input

#### new Input(game)

  Phaser.Input is the Input Manager for all types of Input across Phaser, including mouse, keyboard, touch and MSPointer. The Input manager is updated automatically by the core game loop.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | Current game instance.

  Source:
    - input/Input.js, line 15

### Members

#### <static, constant> MOUSE_OVERRIDES_TOUCH :number

  ##### Type:

  - number
  Source:
    - input/Input.js, line 323

#### <static, constant> MOUSE_TOUCH_COMBINE :number

  ##### Type:

  - number
  Source:
    - input/Input.js, line 335

#### <static, constant> TOUCH_OVERRIDES_MOUSE :number

  ##### Type:

  - number
  Source:
    - input/Input.js, line 329

#### activePointer

  The most recently active Pointer object. When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `activePointer` | Phaser.Pointer |

  Source:
    - input/Input.js, line 212

#### circle

  A Circle object centered on the x/y screen coordinates of the Input. Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `circle` | Phaser.Circle |

  Source:
    - input/Input.js, line 85

#### currentPointers

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `currentPointers` | number | The current number of active Pointers.

  Default Value:
    - 0
  Source:
    - input/Input.js, line 102

#### disabled

  You can disable all Input by setting Input.disabled = true. While set all new input related events will be ignored. If you need to disable just one type of input; for example mouse; use Input.mouse.disabled = true instead

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `disabled` | boolean |

  Default Value:
    - false
  Source:
    - input/Input.js, line 61

#### doubleTapRate

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `doubleTapRate` | number | The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click.

  Default Value:
    - 300
  Source:
    - input/Input.js, line 114

#### game

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | A reference to the currently running game.

  Source:
    - input/Input.js, line 20

#### gamepad

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `gamepad` | Phaser.Gamepad | The Gamepad Input manager.

  Source:
    - input/Input.js, line 242

#### hitCanvas

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `hitCanvas` | HTMLCanvasElement | The canvas to which single pixels are drawn in order to perform pixel-perfect hit detection.

  Default Value:
    - null
  Source:
    - input/Input.js, line 26

#### hitContext

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `hitContext` | CanvasRenderingContext2D | The context of the pixel perfect hit canvas.

  Default Value:
    - null
  Source:
    - input/Input.js, line 32

#### holdRate

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `holdRate` | number | The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event.

  Default Value:
    - 2000
  Source:
    - input/Input.js, line 120

#### interactiveItems

  A list of interactive objects. Te InputHandler components add and remove themselves from this.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `interactiveItems` | Phaser.ArrayList |

  Source:
    - input/Input.js, line 285

#### justPressedRate

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `justPressedRate` | number | The number of milliseconds below which the Pointer is considered justPressed.

  Default Value:
    - 200
  Source:
    - input/Input.js, line 126

#### justReleasedRate

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `justReleasedRate` | number | The number of milliseconds below which the Pointer is considered justReleased .

  Default Value:
    - 200
  Source:
    - input/Input.js, line 132

#### keyboard

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `keyboard` | Phaser.Keyboard | The Keyboard Input manager.

  Source:
    - input/Input.js, line 227

#### maxPointers

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `maxPointers` | number | The maximum number of Pointers allowed to be active at any one time. For lots of games it's useful to set this to 1.

  Default Value:
    - 10
  Source:
    - input/Input.js, line 96

#### minPriorityID

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `minPriorityID` | number | You can tell all Pointers to ignore any object with a priorityID lower than the minPriorityID. Useful when stacking UI layers. Set to zero to disable.

  Default Value:
    - 0
  Source:
    - input/Input.js, line 279

#### mouse

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `mouse` | Phaser.Mouse | The Mouse Input manager.

  Source:
    - input/Input.js, line 222

#### mousePointer

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `mousePointer` | Pointer | The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game.

  Source:
    - input/Input.js, line 217

#### moveCallback

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `moveCallback` | function | An optional callback that will be fired every time the activePointer receives a move event from the DOM. Set to null to disable.

  Source:
    - input/Input.js, line 42

#### moveCallbackContext

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `moveCallbackContext` | object | The context in which the moveCallback will be sent. Defaults to Phaser.Input but can be set to any valid JS object.

  Source:
    - input/Input.js, line 47

#### moveCallbacks

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `moveCallbacks` | array | An array of callbacks that will be fired every time the activePointer receives a move event from the DOM.

  Source:
    - input/Input.js, line 37

#### mspointer

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `mspointer` | Phaser.MSPointer | The MSPointer Input manager.

  Source:
    - input/Input.js, line 237

#### multiInputOverride

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `multiInputOverride` | number | Controls the expected behaviour when using a mouse and touch together on a multi-input device.

  Source:
    - input/Input.js, line 67

#### onDown

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onDown` | Phaser.Signal | A Signal that is dispatched each time a pointer is pressed down.

  Source:
    - input/Input.js, line 258

#### onHold

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onHold` | Phaser.Signal | A Signal that is dispatched each time a pointer is held down.

  Source:
    - input/Input.js, line 273

#### onTap

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onTap` | Phaser.Signal | A Signal that is dispatched each time a pointer is tapped.

  Source:
    - input/Input.js, line 268

#### onUp

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onUp` | Phaser.Signal | A Signal that is dispatched each time a pointer is released.

  Source:
    - input/Input.js, line 263

#### pointer1

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer1` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 160

#### pointer2

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer2` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 165

#### pointer3

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer3` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 170

#### pointer4

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer4` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 175

#### pointer5

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer5` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 180

#### pointer6

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer6` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 185

#### pointer7

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer7` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 190

#### pointer8

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer8` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 195

#### pointer9

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer9` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 200

#### pointer10

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pointer10` | Phaser.Pointer | A Pointer object.

  Source:
    - input/Input.js, line 205

#### <readonly> pollLocked

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pollLocked` | boolean | True if the Input is currently poll rate locked.

  Source:
    - input/Input.js, line 926

#### pollRate

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pollRate` | number | How often should the input pointers be checked for updates? A value of 0 means every single frame (60fps); a value of 1 means every other frame (30fps) and so on.

  Default Value:
    - 0
  Source:
    - input/Input.js, line 53

#### position

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `position` | Phaser.Point | A point object representing the current position of the Pointer.

  Default Value:
    - null
  Source:
    - input/Input.js, line 73

#### recordLimit

  The total number of entries that can be recorded into the Pointer objects tracking history. If the Pointer is tracking one event every 100ms; then a trackLimit of 100 would store the last 10 seconds worth of history.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `recordLimit` | number |

  Default Value:
    - 100
  Source:
    - input/Input.js, line 155

#### recordPointerHistory

  Sets if the Pointer objects should record a history of x/y coordinates they have passed through. The history is cleared each time the Pointer is pressed down. The history is updated at the rate specified in Input.pollRate

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `recordPointerHistory` | boolean |

  Default Value:
    - false
  Source:
    - input/Input.js, line 141

#### recordRate

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `recordRate` | number | The rate in milliseconds at which the Pointer objects should update their tracking history.

  Default Value:
    - 100
  Source:
    - input/Input.js, line 147

#### resetLocked

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `resetLocked` | boolean | If the Input Manager has been reset locked then all calls made to InputManager.reset, such as from a State change, are ignored.

  Default Value:
    - false
  Source:
    - input/Input.js, line 253

#### scale

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `scale` | Phaser.Point | The scale by which all input coordinates are multiplied; calculated by the ScaleManager. In an un-scaled game the values will be x = 1 and y = 1.

  Source:
    - input/Input.js, line 90

#### speed

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `speed` | Phaser.Point | A point object representing the speed of the Pointer. Only really useful in single Pointer games; otherwise see the Pointer objects directly.

  Source:
    - input/Input.js, line 78

#### tapRate

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `tapRate` | number | The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or click.

  Default Value:
    - 200
  Source:
    - input/Input.js, line 108

#### <readonly> totalActivePointers

  The total number of active Pointers

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `totalActivePointers` | number | The total number of active Pointers.

  Source:
    - input/Input.js, line 953

#### <readonly> totalInactivePointers

  The total number of inactive Pointers

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `totalInactivePointers` | number | The total number of inactive Pointers.

  Source:
    - input/Input.js, line 939

#### touch

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `touch` | Phaser.Touch | the Touch Input manager.

  Source:
    - input/Input.js, line 232

#### worldX

  The world X coordinate of the most recently active pointer.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `worldX` | number | The world X coordinate of the most recently active pointer.

  Source:
    - input/Input.js, line 979

#### worldY

  The world Y coordinate of the most recently active pointer.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `worldY` | number | The world Y coordinate of the most recently active pointer.

  Source:
    - input/Input.js, line 992

#### x

  The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `x` | number | The X coordinate of the most recently active pointer.

  Source:
    - input/Input.js, line 892

#### y

  The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `y` | number | The Y coordinate of the most recently active pointer.

  Source:
    - input/Input.js, line 909

### Methods

#### addMoveCallback(callback, callbackContext) → {number}

  Adds a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove. It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best to only use if you've limited input to a single pointer (i.e. mouse or touch). The callback is added to the Phaser.Input.moveCallbacks array and should be removed with Phaser.Input.deleteMoveCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | function | The callback that will be called each time the activePointer receives a DOM move event.
  `callbackContext` | object | The context in which the callback will be called.

  Source:
    - input/Input.js, line 422

  ##### Returns:

  The index of the callback entry. Use this index when calling Input.deleteMoveCallback.

  Type
    number

#### addPointer() → {Phaser.Pointer}

  Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2. If you need more then use this to create a new one, up to a maximum of 10.

  Source:
    - input/Input.js, line 457

  ##### Returns:

  A reference to the new Pointer object that was created.

  Type
    Phaser.Pointer

#### <protected> boot()

  Starts the Input Manager running.

  Source:
    - input/Input.js, line 339

#### deleteMoveCallback(index)

  Adds a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove. It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best to only use if you've limited input to a single pointer (i.e. mouse or touch). The callback is added to the Phaser.Input.moveCallbacks array and should be removed with Phaser.Input.deleteMoveCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `index` | number | The index of the callback to remove.

  Source:
    - input/Input.js, line 439

#### destroy()

  Stops all of the Input Managers from running.

  Source:
    - input/Input.js, line 385

#### getLocalPosition(displayObject, pointer) → {Phaser.Point}

  This will return the local coordinates of the specified displayObject based on the given Pointer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `displayObject` | Phaser.Sprite | Phaser.Image | The DisplayObject to get the local coordinates for.
  `pointer` | Phaser.Pointer | The Pointer to use in the check against the displayObject.

  Source:
    - input/Input.js, line 795

  ##### Returns:

  A point containing the coordinates of the Pointer position relative to the DisplayObject.

  Type
    Phaser.Point

#### getPointer(state) → {Phaser.Pointer}

  Get the next Pointer object whos active property matches the given state

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `state` | boolean | The state the Pointer should be in (false for inactive, true for active).

  Source:
    - input/Input.js, line 693

  ##### Returns:

  A Pointer object or null if no Pointer object matches the requested state.

  Type
    Phaser.Pointer

#### getPointerFromId(pointerId) → {Phaser.Pointer}

  Get the Pointer object whos `pointerId` property matches the given value. The pointerId property is not set until the Pointer has been used at least once, as its populated by the DOM event. Also it can change every time you press the pointer down if the browser recycles it.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pointerId` | number | The Pointer.pointerId value to search for.

  Source:
    - input/Input.js, line 761

  ##### Returns:

  A Pointer object or null if no Pointer object matches the requested identifier.

  Type
    Phaser.Pointer

#### getPointerFromIdentifier(identifier) → {Phaser.Pointer}

  Get the Pointer object whos `identifier` property matches the given identifier value. The identifier property is not set until the Pointer has been used at least once, as its populated by the DOM event. Also it can change every time you press the pointer down, and is not fixed once set. Note: Not all browsers set the identifier property and it's not part of the W3C spec, so you may need getPointerFromId instead.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `identifier` | number | The Pointer.identifier value to search for.

  Source:
    - input/Input.js, line 726

  ##### Returns:

  A Pointer object or null if no Pointer object matches the requested identifier.

  Type
    Phaser.Pointer

#### hitTest(displayObject, pointer, localPoint)

  Tests if the pointer hits the given object.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `displayObject` | DisplayObject | The displayObject to test for a hit.
  `pointer` | Phaser.Pointer | The pointer to use for the test.
  `localPoint` | Phaser.Point | The local translated point.

  Source:
    - input/Input.js, line 816

#### reset(hard)

  Reset all of the Pointers and Input states. The optional `hard` parameter will reset any events or callbacks that may be bound. Input.reset is called automatically during a State change or if a game loses focus / visibility. If you wish to control the reset directly yourself then set InputManager.resetLocked to `true`.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `hard` | boolean | <optional> | false | A soft reset won't reset any events or callbacks that are bound. A hard reset will.

  Source:
    - input/Input.js, line 529

#### resetSpeed(x, y)

  Resets the speed and old position properties.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | number | Sets the oldPosition.x value.
  `y` | number | Sets the oldPosition.y value.

  Source:
    - input/Input.js, line 582

#### setMoveCallback(callback, callbackContext)

  DEPRECATED: This method will be removed in a future major point release. Please use Input.addMoveCallback instead.

  Sets a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove. It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best to only use if you've limited input to a single pointer (i.e. mouse or touch)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | function | The callback that will be called each time the activePointer receives a DOM move event.
  `callbackContext` | object | The context in which the callback will be called.

  Source:
    - input/Input.js, line 404

#### startPointer(event) → {Phaser.Pointer}

  Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `event` | Any | The event data from the Touch event.

  Source:
    - input/Input.js, line 595

  ##### Returns:

  The Pointer object that was started or null if no Pointer object is available.

  Type
    Phaser.Pointer

#### stopPointer(event) → {Phaser.Pointer}

  Stops the matching Pointer object, passing in the event data.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `event` | Any | The event data from the Touch event.

  Source:
    - input/Input.js, line 662

  ##### Returns:

  The Pointer object that was stopped or null if no Pointer object is available.

  Type
    Phaser.Pointer

#### <protected> update()

  Updates the Input Manager. Called by the core Game loop.

  Source:
    - input/Input.js, line 488

#### updatePointer(event) → {Phaser.Pointer}

  Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `event` | Any | The event data from the Touch event.

  Source:
    - input/Input.js, line 631

  ##### Returns:

  The Pointer object that was updated or null if no Pointer object is available.

  Type
    Phaser.Pointer