# Class: GamepadButton

## Phaser. GamepadButton

If you need more fine-grained control over the handling of specific buttons you can create and use Phaser.GamepadButton objects.

#### new GamepadButton(game, buttoncode)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | Current game instance.
  `buttoncode` | number | The button code this GamepadButton is responsible for.

  Source:
    - input/GamepadButton.js, line 14

### Members

#### buttonCode

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `buttonCode` | number | The buttoncode of this button.

  Source:
    - input/GamepadButton.js, line 68

#### duration

  If the button is down this value holds the duration of that button press and is constantly updated. If the button is up it holds the duration of the previous down session.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `duration` | number | The number of milliseconds this button has been held down for.

  Default Value:
    - 0
  Source:
    - input/GamepadButton.js, line 45

#### game

  ##### Properties:

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

  Source:
    - input/GamepadButton.js, line 19

#### isDown

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `isDown` | boolean | The "down" state of the button.

  Default Value:
    - false
  Source:
    - input/GamepadButton.js, line 25

#### isUp

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `isUp` | boolean | The "up" state of the button.

  Default Value:
    - true
  Source:
    - input/GamepadButton.js, line 31

#### onDown

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onDown` | Phaser.Signal | This Signal is dispatched every time this GamepadButton is pressed down. It is only dispatched once (until the button is released again).

  Source:
    - input/GamepadButton.js, line 73

#### onFloat

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onFloat` | Phaser.Signal | This Signal is dispatched every time this GamepadButton changes floating value (between (but not exactly) 0 and 1)

  Source:
    - input/GamepadButton.js, line 83

#### onUp

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onUp` | Phaser.Signal | This Signal is dispatched every time this GamepadButton is pressed down. It is only dispatched once (until the button is released again).

  Source:
    - input/GamepadButton.js, line 78

#### repeats

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `repeats` | number | If a button is held down this holds down the number of times the button has 'repeated'.

  Default Value:
    - 0
  Source:
    - input/GamepadButton.js, line 57

#### timeDown

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `timeDown` | number | The timestamp when the button was last pressed down.

  Default Value:
    - 0
  Source:
    - input/GamepadButton.js, line 37

#### timeUp

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `timeUp` | number | The timestamp when the button was last released.

  Default Value:
    - 0
  Source:
    - input/GamepadButton.js, line 51

#### value

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `value` | number | Button value. Mainly useful for checking analog buttons (like shoulder triggers)

  Default Value:
    - 0
  Source:
    - input/GamepadButton.js, line 63

### Methods

#### justPressed(duration) → {boolean}

  Returns the "just pressed" state of this button. Just pressed is considered true if the button was pressed down within the duration given (default 250ms).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `duration` | number | <optional> | 250 | The duration below which the button is considered as being just pressed.

  Source:
    - input/GamepadButton.js, line 146

  ##### Returns:

  True if the button is just pressed otherwise false.

  Type
    boolean

#### justPressed(duration) → {boolean}

  Returns the "just released" state of this button. Just released is considered as being true if the button was released within the duration given (default 250ms).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `duration` | number | <optional> | 250 | The duration below which the button is considered as being just released.

  Source:
    - input/GamepadButton.js, line 160

  ##### Returns:

  True if the button is just pressed otherwise false.

  Type
    boolean

#### <protected> processButtonDown(value)

  Called automatically by Phaser.SinglePad.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | Object | Button value

  Source:
    - input/GamepadButton.js, line 89

#### <protected> processButtonFloat(value)

  Called automatically by Phaser.Gamepad.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | Object | Button value

  Source:
    - input/GamepadButton.js, line 133

#### <protected> processButtonUp(value)

  Called automatically by Phaser.SinglePad.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | Object | Button value

  Source:
    - input/GamepadButton.js, line 116