Namespace: Keyboard

Phaser.Input. Keyboard

Classes

Key
KeyboardManager
KeyboardPlugin
KeyCombo

Namespaces

Events

Members


<static, readonly> KeyCodes :integer

Keyboard Codes.

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

Methods


<static> DownDuration(key [, duration])

Returns true if the Key was pressed down within the duration value given, or false if it either isn't down, or was pressed down longer ago than then given duration.

Parameters:
Name Type Argument Default Description
key Phaser.Input.Keyboard.Key

The Key object to test.

duration integer <optional>
50

The duration, in ms, within which the key must have been pressed down.

Since: 3.0.0
Source: src/input/keyboard/keys/DownDuration.js (Line 7)
Returns:

true if the Key was pressed down within duration ms, otherwise false.

Type
boolean

<static> JustDown(key)

The justDown value allows you to test if this Key has just been pressed down or not.

When you check this value it will return true if the Key is down, otherwise false.

You can only call justDown once per key press. It will only return true once, until the Key is released and pressed down again. This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop.

Parameters:
Name Type Description
key Phaser.Input.Keyboard.Key

The Key to check to see if it's just down or not.

Since: 3.0.0
Source: src/input/keyboard/keys/JustDown.js (Line 7)
Returns:

true if the Key was just pressed, otherwise false.

Type
boolean

<static> JustUp(key)

The justUp value allows you to test if this Key has just been released or not.

When you check this value it will return true if the Key is up, otherwise false.

You can only call JustUp once per key release. It will only return true once, until the Key is pressed down and released again. This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop.

Parameters:
Name Type Description
key Phaser.Input.Keyboard.Key

The Key to check to see if it's just up or not.

Since: 3.0.0
Source: src/input/keyboard/keys/JustUp.js (Line 7)
Returns:

true if the Key was just released, otherwise false.

Type
boolean

<static> UpDuration(key [, duration])

Returns true if the Key was released within the duration value given, or false if it either isn't up, or was released longer ago than then given duration.

Parameters:
Name Type Argument Default Description
key Phaser.Input.Keyboard.Key

The Key object to test.

duration integer <optional>
50

The duration, in ms, within which the key must have been released.

Since: 3.0.0
Source: src/input/keyboard/keys/UpDuration.js (Line 7)
Returns:

true if the Key was released within duration ms, otherwise false.

Type
boolean

Type Definitions


CursorKeys

Type:
  • object
Properties:
Name Type Argument Description
up Phaser.Input.Keyboard.Key <optional>

A Key object mapping to the UP arrow key.

down Phaser.Input.Keyboard.Key <optional>

A Key object mapping to the DOWN arrow key.

left Phaser.Input.Keyboard.Key <optional>

A Key object mapping to the LEFT arrow key.

right Phaser.Input.Keyboard.Key <optional>

A Key object mapping to the RIGHT arrow key.

space Phaser.Input.Keyboard.Key <optional>

A Key object mapping to the SPACE BAR key.

shift Phaser.Input.Keyboard.Key <optional>

A Key object mapping to the SHIFT key.

Source: src/input/keyboard/KeyboardPlugin.js (Line 365)