Skip to content

Commit 11512e1

Browse files
committed
Keyboard.JustDown and Keyboard.JustUp were being reset too early, causing them to fail when called in update loops. Fix phaserjs#3490
1 parent 5fb57e1 commit 11512e1

5 files changed

Lines changed: 19 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ being passed to the simulation. The default value is 1 to remain consistent with
3131
* The HueToComponent module was not correctly exporting itself. Fix #3482 (thanks @jdotrjs)
3232
* Matter.World was using `setZ` instead of `setDepth` for the Debug Graphics Layer, causing it to appear behind objects in some display lists.
3333
* Game.destroy now checks to see if the `renderer` exists before calling destroy on it. Fix #3498 (thanks @Huararanga)
34+
* Keyboard.JustDown and Keyboard.JustUp were being reset too early, causing them to fail when called in `update` loops. Fix #3490 (thanks @belen-albeza)
3435

3536
### Updates
3637

src/input/keyboard/keys/JustDown.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919
*/
2020
var JustDown = function (key)
2121
{
22-
var current = false;
23-
24-
if (key.isDown)
22+
if (key._justDown)
2523
{
26-
current = key._justDown;
2724
key._justDown = false;
28-
}
2925

30-
return current;
26+
return true;
27+
}
28+
else
29+
{
30+
return false;
31+
}
3132
};
3233

3334
module.exports = JustDown;

src/input/keyboard/keys/JustUp.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919
*/
2020
var JustUp = function (key)
2121
{
22-
var current = false;
23-
24-
if (key.isDown)
22+
if (key._justUp)
2523
{
26-
current = key._justUp;
2724
key._justUp = false;
28-
}
2925

30-
return current;
26+
return true;
27+
}
28+
else
29+
{
30+
return false;
31+
}
3132
};
3233

3334
module.exports = JustUp;

src/input/keyboard/keys/ProcessKeyDown.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ var ProcessKeyDown = function (key, event)
4040
key.isUp = false;
4141
key.timeDown = event.timeStamp;
4242
key.duration = 0;
43+
key._justDown = true;
44+
key._justUp = false;
4345
}
4446

4547
key.repeats++;
4648

47-
key._justDown = true;
48-
key._justUp = false;
49-
5049
return key;
5150
};
5251

src/input/keyboard/keys/ResetKey.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66

77
/**
8-
* Resets a Key object back to its default settings.
9-
* Optionally resets the keyCode as well.
8+
* Resets a Key object back to its default settings.
9+
* Optionally resets the keyCode as well.
1010
*
1111
* @function Phaser.Input.Keyboard.Keys.ResetKey
1212
* @since 3.0.0

0 commit comments

Comments
 (0)