Skip to content

Commit

Permalink
Merge pull request #4901 from peppy/key-repeat-disable
Browse files Browse the repository at this point in the history
Add back ability to disable key repeat firing in `KeyBindingContainer`
  • Loading branch information
smoogipoo authored Nov 18, 2021
2 parents dd74999 + 4473d71 commit 49c9543
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions osu.Framework/Input/Bindings/KeyBindingContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ protected override bool Handle(UIEvent e)

private bool handleRepeat(InputState state)
{
if (!HandleRepeats)
return false;

if (pressedActions.Count == 0)
return false;

Expand Down Expand Up @@ -415,6 +418,16 @@ public abstract class KeyBindingContainer : Container

public abstract IEnumerable<IKeyBinding> DefaultKeyBindings { get; }

/// <summary>
/// Whether key repeat events should be sent. Defaults to <c>true</c>.
/// </summary>
/// <remarks>
/// Key repeats will invoke actions at the same rates as <see cref="Drawable.OnKeyDown"/> events.
/// Disabling this is recommended if you either don't require key repeats (quite often applicable to gameplay input),
/// or want a custom repeat rate.
/// </remarks>
protected virtual bool HandleRepeats => true;

protected override void LoadComplete()
{
base.LoadComplete();
Expand Down

0 comments on commit 49c9543

Please sign in to comment.