From 8771c816496c31291f5de26a7faa6865b69c749d Mon Sep 17 00:00:00 2001 From: cjw6k <68166329+cjw6k@users.noreply.github.com> Date: Sun, 27 Dec 2020 17:24:14 -0400 Subject: [PATCH 1/2] Check event.type in duplicate event bailout Fixes #5471. --- src/input/keyboard/KeyboardPlugin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/input/keyboard/KeyboardPlugin.js b/src/input/keyboard/KeyboardPlugin.js index 5d97bfd04c..f66fac1a32 100644 --- a/src/input/keyboard/KeyboardPlugin.js +++ b/src/input/keyboard/KeyboardPlugin.js @@ -747,7 +747,7 @@ var KeyboardPlugin = new Class({ } // Duplicate event bailout - if (code === this.prevCode && event.timeStamp === this.prevTime) + if (code === this.prevCode && event.timeStamp === this.prevTime && event.type === this.prevType) { // On some systems, the exact same event will fire multiple times. This prevents it. continue; @@ -755,6 +755,7 @@ var KeyboardPlugin = new Class({ this.prevCode = code; this.prevTime = event.timeStamp; + this.prevType = event.type; if (event.type === 'keydown') { From 19c28741669f40a6f4855f3bad378032d80c6cca Mon Sep 17 00:00:00 2001 From: cjw6k <68166329+cjw6k@users.noreply.github.com> Date: Mon, 28 Dec 2020 17:37:54 -0400 Subject: [PATCH 2/2] Added prevType to constructor. --- src/input/keyboard/KeyboardPlugin.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/input/keyboard/KeyboardPlugin.js b/src/input/keyboard/KeyboardPlugin.js index f66fac1a32..4151d47654 100644 --- a/src/input/keyboard/KeyboardPlugin.js +++ b/src/input/keyboard/KeyboardPlugin.js @@ -167,6 +167,16 @@ var KeyboardPlugin = new Class({ */ this.prevTime = 0; + /** + * Internal repeat key flag. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#prevType + * @type {string} + * @private + * @since 3.50.1 + */ + this.prevType = null; + sceneInputPlugin.pluginEvents.once(InputEvents.BOOT, this.boot, this); sceneInputPlugin.pluginEvents.on(InputEvents.START, this.start, this); },