Class: Key

Phaser.Input.Keyboard. Key

A generic Key object which can be passed to the Process functions (and so on)
keycode must be an integer


new Key(keyCode)

Parameters:
Name Type Description
keyCode integer

The keycode of this key.

Since: 3.0.0
Source: src/input/keyboard/keys/Key.js (Line 9)

Members


altKey :boolean

The down state of the ALT key, if pressed at the same time as this key.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/input/keyboard/keys/Key.js (Line 85)

ctrlKey :boolean

The down state of the CTRL key, if pressed at the same time as this key.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/input/keyboard/keys/Key.js (Line 95)

duration :number

The number of milliseconds this key was held down for in the previous down - up sequence.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/input/keyboard/keys/Key.js (Line 135)

enabled :boolean

Can this Key be processed?

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/input/keyboard/keys/Key.js (Line 55)

isDown :boolean

The "down" state of the key. This will remain true for as long as the keyboard thinks this key is held down.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/input/keyboard/keys/Key.js (Line 65)

isUp :boolean

The "up" state of the key. This will remain true for as long as the keyboard thinks this key is up.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/input/keyboard/keys/Key.js (Line 75)

keyCode :integer

The keycode of this key.

Type:
  • integer
Since: 3.0.0
Source: src/input/keyboard/keys/Key.js (Line 27)

location :number

The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/input/keyboard/keys/Key.js (Line 115)

originalEvent :KeyboardEvent

The original DOM event.

Type:
  • KeyboardEvent
Since: 3.0.0
Source: src/input/keyboard/keys/Key.js (Line 36)

preventDefault :boolean

Should this Key prevent event propagation?

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/input/keyboard/keys/Key.js (Line 45)

repeats :number

If a key is held down this holds down the number of times the key has 'repeated'.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/input/keyboard/keys/Key.js (Line 155)

shiftKey :boolean

The down state of the SHIFT key, if pressed at the same time as this key.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/input/keyboard/keys/Key.js (Line 105)

timeDown :number

The timestamp when the key was last pressed down.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/input/keyboard/keys/Key.js (Line 125)

timeUp :number

The timestamp when the key was last released.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/input/keyboard/keys/Key.js (Line 145)

Methods


<static> reset()

Resets this Key object back to its default un-pressed state.

Since: 3.6.0
Source: src/input/keyboard/keys/Key.js (Line 198)
Returns:

This Key instance.

Type
Phaser.Input.Keyboard.Key