Skip to content

Commit 6c7437c

Browse files
authored
Merge pull request phaserjs#5198 from samme/feature/KeyboardPlugin-removeAllKeys
Add KeyboardPlugin#removeAllKeys
2 parents 672c08c + af141f6 commit 6c7437c

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/input/keyboard/KeyboardPlugin.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,38 @@ var KeyboardPlugin = new Class({
566566
return this;
567567
},
568568

569+
/**
570+
* Removes all Key objects created by _this_ Keyboard Plugin.
571+
*
572+
* @method Phaser.Input.Keyboard.KeyboardPlugin#removeAllKeys
573+
* @since 3.24.0
574+
*
575+
* @param {boolean} [destroy=false] - Call `Key.destroy` on each removed Key object?
576+
*
577+
* @return {this} This KeyboardPlugin object.
578+
*/
579+
removeAllKeys: function (destroy)
580+
{
581+
var keys = this.keys;
582+
583+
for (var i = 0; i < keys.length; i++)
584+
{
585+
var key = keys[i];
586+
587+
if (key)
588+
{
589+
keys[i] = undefined;
590+
591+
if (destroy)
592+
{
593+
key.destroy();
594+
}
595+
}
596+
}
597+
598+
return this;
599+
},
600+
569601
/**
570602
* Creates a new KeyCombo.
571603
*

0 commit comments

Comments
 (0)