phaser/src/input/keyboard/combo/AdvanceKeyCombo.js
2023-01-02 17:36:27 +00:00

36 lines
928 B
JavaScript

/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013-2023 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Used internally by the KeyCombo class.
* Return `true` if it reached the end of the combo, `false` if not.
*
* @function Phaser.Input.Keyboard.AdvanceKeyCombo
* @private
* @since 3.0.0
*
* @param {KeyboardEvent} event - The native Keyboard Event.
* @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to advance.
*
* @return {boolean} `true` if it reached the end of the combo, `false` if not.
*/
var AdvanceKeyCombo = function (event, combo)
{
combo.timeLastMatched = event.timeStamp;
combo.index++;
if (combo.index === combo.size)
{
return true;
}
else
{
combo.current = combo.keyCodes[combo.index];
return false;
}
};
module.exports = AdvanceKeyCombo;