Phaser API Documentation

  Version: 
createCombo(keys, [config])

Description:

Creates a new KeyCombo.

A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them it will emit a keycombomatch event from this Keyboard Plugin.

The keys to be listened for can be defined as:

A string (i.e. 'ATARI') An array of either integers (key codes) or strings, or a mixture of both An array of objects (such as Key objects) with a public 'keyCode' property

For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) you could pass the following array of key codes:

this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true });

this.input.keyboard.on('keycombomatch', function (event) {
    console.log('Konami Code entered!');
});

Or, to listen for the user entering the word PHASER:

this.input.keyboard.createCombo('PHASER');

Parameters:

name type arguments description
keys string | Array.<number> | Array.<object>

The keys that comprise this combo.

config Phaser.Types.Input.Keyboard.KeyComboConfig <optional>

A Key Combo configuration object.

Returns:
Description:

The new KeyCombo object.

Since: 3.10.0