Table of Contents

Interface IHotkeyService

Namespace
BlazOrbit.Hotkeys
Assembly
BlazOrbit.Hotkeys.dll

Registry of keyboard shortcuts. The matching BOBHotkeyHost component installs a document keydown listener via JS interop and forwards the canonical combo to every registered handler.

public interface IHotkeyService

Remarks

Combo grammar (case-insensitive, modifiers before the key, fixed order): "ctrl+shift+s", "meta+k", "?", "escape". The bridge skips keystrokes that originate inside <input>, <textarea>, <select> or contentEditable targets - typed text never collides with shortcuts.

Properties

RegisteredHotkeys

Currently registered hotkeys, useful for a cheat-sheet UI.

IReadOnlyList<HotkeyDescriptor> RegisteredHotkeys { get; }

Property Value

IReadOnlyList<HotkeyDescriptor>

Methods

DispatchAsync(string)

Internal hook called by BOBHotkeyHost when JS dispatches a keydown. Returns true when at least one handler matched and requested preventDefault

  • retained as a fallback signal, but the synchronous suppression now lives in JS via the Registered / Unregistered events.
Task<bool> DispatchAsync(string combo)

Parameters

combo string

Returns

Task<bool>

Register(string, string, Func<Task>, HotkeyScope, bool)

Registers handler against combo. The returned System.IDisposable removes the entry - call it from IDisposable.Dispose to scope the shortcut to a page / component lifetime.

IDisposable Register(string combo, string description, Func<Task> handler, HotkeyScope scope = HotkeyScope.Global, bool preventDefault = true)

Parameters

combo string

Canonical combo string. Case-insensitive; whitespace around + is OK.

description string

Short human label used by the cheat-sheet.

handler Func<Task>

Async callback invoked when the combo fires.

scope HotkeyScope

Scope tag; surfaced via RegisteredHotkeys.

preventDefault bool

When true, the JS bridge calls event.preventDefault() synchronously on match so the browser's default action never fires.

Returns

IDisposable

Events

Registered

Raised when a new hotkey is registered. BOBHotkeyHost subscribes so it can push the descriptor to the JS bridge, which is what enables synchronous preventDefault() on match - async dispatch alone is too late to suppress the browser's default action (e.g. Ctrl+S Save dialog).

event Action<HotkeyDescriptor>? Registered

Event Type

Action<HotkeyDescriptor>

Unregistered

Raised when a previously-registered hotkey is removed (via the returned System.IDisposable).

event Action<HotkeyDescriptor>? Unregistered

Event Type

Action<HotkeyDescriptor>