@@ -12,36 +12,54 @@ var ResetKeyCombo = require('./ResetKeyCombo');
1212/**
1313 * @callback KeyboardKeydownCallback
1414 *
15- * @param {KeyboardEvent } event - [description]
15+ * @param {KeyboardEvent } event - The Keyboard Event.
1616 */
1717
1818/**
1919 * @typedef {object } KeyComboConfig
2020 *
21- * @property {boolean } [resetOnWrongKey=true] - [description]
22- * @property {number } [maxKeyDelay=0] - [description]
23- * @property {boolean } [resetOnMatch=false] - [description]
24- * @property {boolean } [deleteOnMatch=false] - [description]
21+ * @property {boolean } [resetOnWrongKey=true] - If they press the wrong key do we reset the combo?
22+ * @property {number } [maxKeyDelay=0] - The max delay in ms between each key press. Above this the combo is reset. 0 means disabled.
23+ * @property {boolean } [resetOnMatch=false] - If previously matched and they press the first key of the combo again, will it reset?
24+ * @property {boolean } [deleteOnMatch=false] - If the combo matches, will it delete itself?
2525 */
2626
2727/**
2828 * @classdesc
29- * [description]
29+ * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them
30+ * it will emit a `keycombomatch` event from the Keyboard Manager.
3031 *
31- * ` keys` argument can be:
32+ * The keys to be listened for can be defined as :
3233 *
33- * A string (ATARI)
34+ * A string (i.e. ' ATARI' )
3435 * An array of either integers (key codes) or strings, or a mixture of both
3536 * An array of objects (such as Key objects) with a public 'keyCode' property
3637 *
38+ * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right)
39+ * you could pass the following array of key codes:
40+ *
41+ * ```javascript
42+ * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true });
43+ *
44+ * this.input.keyboard.on('keycombomatch', function (event) {
45+ * console.log('Konami Code entered!');
46+ * });
47+ * ```
48+ *
49+ * Or, to listen for the user entering the word PHASER:
50+ *
51+ * ```javascript
52+ * this.input.keyboard.createCombo('PHASER');
53+ * ```
54+ *
3755 * @class KeyCombo
3856 * @memberOf Phaser.Input.Keyboard
3957 * @constructor
4058 * @since 3.0.0
4159 *
42- * @param {Phaser.Input.Keyboard.KeyboardManager } keyboardManager - [description]
43- * @param {(string|integer[]|object[]) } keys - [description]
44- * @param {KeyComboConfig } [config] - [description]
60+ * @param {Phaser.Input.Keyboard.KeyboardManager } keyboardManager - A reference to the Keyboard Manager.
61+ * @param {(string|integer[]|object[]) } keys - The keys that comprise this combo.
62+ * @param {KeyComboConfig } [config] - A Key Combo configuration object.
4563 */
4664var KeyCombo = new Class ( {
4765
@@ -58,7 +76,7 @@ var KeyCombo = new Class({
5876 }
5977
6078 /**
61- * [description]
79+ * A reference to the Keyboard Manager
6280 *
6381 * @name Phaser.Input.Keyboard.KeyCombo#manager
6482 * @type {Phaser.Input.Keyboard.KeyboardManager }
@@ -67,7 +85,7 @@ var KeyCombo = new Class({
6785 this . manager = keyboardManager ;
6886
6987 /**
70- * [description]
88+ * A flag that controls if this Key Combo is actively processing keys or not.
7189 *
7290 * @name Phaser.Input.Keyboard.KeyCombo#enabled
7391 * @type {boolean }
@@ -77,7 +95,7 @@ var KeyCombo = new Class({
7795 this . enabled = true ;
7896
7997 /**
80- * [description]
98+ * An array of the keycodes that comprise this combo.
8199 *
82100 * @name Phaser.Input.Keyboard.KeyCombo#keyCodes
83101 * @type {array }
@@ -119,7 +137,7 @@ var KeyCombo = new Class({
119137 * The current index of the key being waited for in the 'keys' string.
120138 *
121139 * @name Phaser.Input.Keyboard.KeyCombo#index
122- * @type {number }
140+ * @type {integer }
123141 * @default 0
124142 * @since 3.0.0
125143 */
@@ -185,7 +203,7 @@ var KeyCombo = new Class({
185203 this . maxKeyDelay = GetFastValue ( config , 'maxKeyDelay' , 0 ) ;
186204
187205 /**
188- * If previously matched and they press Key 1 again, will it reset?
206+ * If previously matched and they press the first key of the combo again, will it reset?
189207 *
190208 * @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch
191209 * @type {boolean }
@@ -231,9 +249,10 @@ var KeyCombo = new Class({
231249 } ;
232250
233251 /**
234- * [description]
252+ * The internal Key Down handler.
235253 *
236254 * @name Phaser.Input.Keyboard.KeyCombo#onKeyDown
255+ * @private
237256 * @type {KeyboardKeydownCallback }
238257 * @since 3.0.0
239258 */
@@ -260,7 +279,7 @@ var KeyCombo = new Class({
260279 } ,
261280
262281 /**
263- * [description]
282+ * Destroys this Key Combo and all of its references.
264283 *
265284 * @method Phaser.Input.Keyboard.KeyCombo#destroy
266285 * @since 3.0.0
@@ -271,7 +290,8 @@ var KeyCombo = new Class({
271290 this . keyCodes = [ ] ;
272291
273292 this . manager . off ( 'keydown' , this . onKeyDown ) ;
274- this . manager = undefined ;
293+
294+ this . manager = null ;
275295 }
276296
277297} ) ;
0 commit comments