Fix oftentimes doesn't trigger #1903 #1483

The fix prevents the first Space keydown from being locked out before it is actually handled, so subsequent Space presses are no longer discarded.
This commit is contained in:
ema
2026-04-23 02:28:45 +08:00
parent c1433610b4
commit 1803022ec6
+8 -2
View File
@@ -46,7 +46,8 @@ internal class KeystrokeDispatcher : IDisposable
_validKeys =
[
Keys.Up, Keys.Down, Keys.Left, Keys.Right,
Keys.Enter, Keys.Space, Keys.Escape, Keys.F5, Keys.F11
Keys.Enter, Keys.Space, Keys.Escape,
Keys.F5, Keys.F11,
];
}
@@ -90,7 +91,7 @@ internal class KeystrokeDispatcher : IDisposable
{
if (_spaceIsDown)
return;
_spaceIsDown = true;
_spaceHoldTick = DateTime.Now.Ticks;
}
@@ -109,7 +110,12 @@ internal class KeystrokeDispatcher : IDisposable
{
if (isKeyDown || e.KeyCode != Keys.Space ||
DateTime.Now.Ticks - _spaceHoldTick >= HOLD_TO_PREVIEW_DURATION)
{
InvokeRoutine(e.KeyCode, isKeyDown);
if (isKeyDown && e.KeyCode == Keys.Space)
_spaceIsDown = true;
}
}
// when the key has been released, reset variables