Skip to content

Keybinds

XtraCube edited this page Feb 27, 2026 · 1 revision

Mira API provides a keybind system built on top of Rewired. Keybinds can be created for custom abilities, assigned default keys, combined with modifier keys, and attached to buttons in the HUD.

Global Keybinds

Before creating your own keybinds, check whether one of the shared global keybinds from MiraGlobalKeybinds fits your use case. Using global keybinds improves compatibility between mods because multiple mods can listen to the same keybind without conflicts.

Property Default Key Description
MiraGlobalKeybinds.PrimaryAbility T Intended for a role or modifier's primary ability.
MiraGlobalKeybinds.SecondaryAbility Y Intended for a secondary ability.
MiraGlobalKeybinds.TertiaryAbility U Intended for a tertiary ability.
MiraGlobalKeybinds.ModifierPrimaryAbility I Intended for a modifier's primary ability.
MiraGlobalKeybinds.ModifierSecondaryAbility O Intended for a modifier's secondary ability.
MiraGlobalKeybinds.ModifierTertiaryAbility P Intended for a modifier's tertiary ability.
// Attach a global keybind to a button
public override BaseKeybind? Keybind => MiraGlobalKeybinds.PrimaryAbility;

Creating Custom Keybinds

Create a static class decorated with [RegisterCustomKeybinds]. Each MiraKeybind property in the class is automatically discovered and registered.

[RegisterCustomKeybinds]
public static class ExampleKeybinds
{
    // Shift+C triggers a neutral win (for testing purposes).
    public static MiraKeybind NeutralWinKeybind { get; } =
        new("Neutral Win", KeyboardKeyCode.C, [ModifierKey.Shift]);
}

MiraKeybind Constructor

new MiraKeybind(
    string name,
    KeyboardKeyCode? defaultKeycode,
    ModifierKey[]? modifierKeys = null,
    bool exclusive = true)
Parameter Description
name The display name of the keybind. Also used to derive the Rewired action ID (lowercased, spaces replaced with underscores).
defaultKeycode The default keyboard key. Pass null or KeyboardKeyCode.None for no default.
modifierKeys Up to three Rewired ModifierKey values (e.g., ModifierKey.Shift, ModifierKey.Control).
exclusive When true, Mira will warn on conflict if another exclusive keybind uses the same key. Defaults to true.

MiraKeybind Properties

Property Type Description
Name string The display name.
DefaultKey KeyboardKeyCode The default assigned key.
ModifierKeys ModifierKey[] The required modifier keys.
Exclusive bool Whether conflict checking is enabled.
CurrentKey KeyboardKeyCode The currently assigned key (may differ from DefaultKey if remapped).
Id string The Rewired action ID derived from the name.

Listening to Keybinds

Use OnActivate to register a callback that fires when the keybind is pressed.

ExampleKeybinds.NeutralWinKeybind.OnActivate(() =>
{
    // Triggered when Shift+C is pressed.
    CustomGameOver.Trigger<NeutralKillerGameOver>(...);
});

To unregister a callback, use RemoveOnActivate with the same delegate reference. However, it is generally better to add a guard condition inside your callback rather than removing it.

You can also call Invoke() on any keybind to trigger it programmatically.

Attaching Keybinds to Buttons

The Keybind property on CustomActionButton accepts any BaseKeybind. When set, Mira renders a small keybind indicator on the button and triggers the button when the keybind fires.

public class MyAbilityButton : CustomActionButton
{
    public override BaseKeybind? Keybind => MiraGlobalKeybinds.PrimaryAbility;
    // ... rest of the button
}

See Custom Buttons for full button documentation.

Vanilla Keybinds

VanillaKeybind wraps an existing Rewired input action by its integer action ID. This is useful when you want to listen to or react alongside a vanilla input.

var killKeybind = new VanillaKeybind(actionId);
killKeybind.OnActivate(() => { /* ... */ });

The Button property (ActionButton?) gives access to the ActionButton this keybind is associated with, if any.

Clone this wiki locally