Merge pull request #5198 from samme/feature/KeyboardPlugin-removeAllKeys

Add KeyboardPlugin#removeAllKeys
This commit is contained in:
Richard Davey 2020-07-13 13:04:53 +01:00 committed by GitHub
commit 6c7437cdc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -566,6 +566,38 @@ var KeyboardPlugin = new Class({
return this;
},
/**
* Removes all Key objects created by _this_ Keyboard Plugin.
*
* @method Phaser.Input.Keyboard.KeyboardPlugin#removeAllKeys
* @since 3.24.0
*
* @param {boolean} [destroy=false] - Call `Key.destroy` on each removed Key object?
*
* @return {this} This KeyboardPlugin object.
*/
removeAllKeys: function (destroy)
{
var keys = this.keys;
for (var i = 0; i < keys.length; i++)
{
var key = keys[i];
if (key)
{
keys[i] = undefined;
if (destroy)
{
key.destroy();
}
}
}
return this;
},
/**
* Creates a new KeyCombo.
*