ShortcutGuide

Description

The "keyboard shortcuts" sheet, listing an app's shortcuts in titled sections and optionally answering them

ShortcutGuide is the sheet an app opens from its help menu or with Ctrl+/: a Modal whose content is a list of sections, each row a description on the left and its keys on the right, drawn by KeyboardShortcut. It takes the same key names KeyboardShortcut.Matches tests, so a shortcut is declared once and what is listed cannot drift from what is bound.

Usage

Section(title) starts a section — every shortcut added after it is listed under it, until the next Section(...); pass null or empty for an untitled one. Shortcut(description, params keys) adds a row, with key names such as "Ctrl", "Shift", "Enter", "Escape" and "ArrowUp", so modifiers show as ⌘/⇧ on macOS and Ctrl/Shift elsewhere. Describe what the shortcut does ("Quick chat or search"), not what the command is called in the code.

OnPressed(action) gives the shortcut added last something to do. A row without one is listed but not answered, which is right when the key belongs to some other component. Handle(KeyboardEvent) runs the first listed shortcut the event matches and returns whether one did, so the caller stops the event only when the press was taken:

window.addEventListener("keydown", ev =>
{
    if (guide.Handle(ev.As<KeyboardEvent>())) StopEvent(ev);
});

Show(), Hide(onHidden) and Toggle() drive the sheet, and IsVisible reads the state. ShowEmbedded() returns a component to place in a settings or help page instead of floating it. SetTitle(string), Width(UnitSize) (560px by default), LightDismiss() (on by default) / NoLightDismiss() and OnShow / OnHide configure the modal underneath, and the sizing helpers apply to it as they do on Modal.

Var(out var self) hands the guide to its own rows, which is how the Ctrl+/ entry both advertises and performs the toggle.

API reference

class

ShortcutGuide

public sealed class ShortcutGuide : IComponent, ISpecialCaseStyling

A modal listing an application's keyboard shortcuts, grouped into titled sections, each row a description on the left and the keys on the right as KeyboardShortcut chips. A shortcut is declared here with the same key names Matches tests, so a guide can also answer the presses it advertises: give an entry an action with OnPressed and call Handle from the application's keydown handler.

Namespace
Tesserae
Implements
IComponent, ISpecialCaseStyling

Constructors

NameDescription
ShortcutGuideInitializes a new instance of this class.
Constructor
ShortcutGuide
public ShortcutGuide(string title = "Keyboard shortcuts")

Initializes a new instance of this class.

Parameters

title
The modal's title.

Properties

NameDescription
StylingContainerGets the styling container for the guide, so the sizing helpers reach the modal itself.
PropagateStylesToWrapperGets whether a sizing helper applied to this component should tag it so a wrapper-building container hoists the style onto the wrapper.
IsVisibleGets a value indicating whether the guide is currently shown.
Property
ShortcutGuide.StylingContainer
public HTMLElement StylingContainer

Gets the styling container for the guide, so the sizing helpers reach the modal itself.

Property
ShortcutGuide.PropagateStylesToWrapper
public bool PropagateStylesToWrapper

Gets whether a sizing helper applied to this component should tag it so a wrapper-building container hoists the style onto the wrapper.

Property
ShortcutGuide.IsVisible
public bool IsVisible

Gets a value indicating whether the guide is currently shown.

Methods

NameDescription
SectionStarts a new section. Every shortcut added after this call is listed under it, until the next Section.
ShortcutAdds a shortcut to the current section, creating an untitled one if Section has not been called yet.
OnPressedSets the action the last added shortcut runs when Handle sees it pressed. A shortcut without one is listed but not answered - which is right when whatever owns the key already handles it.
HandleRuns the action of the first listed shortcut that e matches, and answers whether one did - so a caller can stop the event only when the press was taken.
SetTitleSets the title of the component.
WidthSets the width of the component.
WSets the width of the component.
LightDismissEnables light-dismiss behaviour (clicking outside the guide closes it). It is on by default.
NoLightDismissRemoves / disables the light dismiss on the component.
OnShowRegisters a callback invoked when the guide is shown.
OnHideRegisters a callback invoked when the guide is hidden.
ShowShows the component.
HideHides the component.
ToggleShows the guide if it is hidden and hides it if it is shown, which is what the shortcut that opens it usually does.
ShowEmbeddedReturns the guide as a component to place in the page, instead of showing it as a modal layer.
RenderRenders the component's root HTML element.
Method
ShortcutGuide.Section
public ShortcutGuide Section(string title)

Starts a new section. Every shortcut added after this call is listed under it, until the next Section.

Parameters

title
The section's title, e.g. "General". Pass null or empty for an untitled section.
Method
ShortcutGuide.Shortcut
public ShortcutGuide Shortcut(string description, params string[] keys)

Adds a shortcut to the current section, creating an untitled one if Section has not been called yet.

Parameters

description
What the shortcut does, e.g. "Quick chat or search".
keys
The keys, in the names KeyboardShortcut takes, e.g. "Ctrl", "K".
Method
ShortcutGuide.OnPressed
public ShortcutGuide OnPressed(Action action)

Sets the action the last added shortcut runs when Handle sees it pressed. A shortcut without one is listed but not answered - which is right when whatever owns the key already handles it.

Method
ShortcutGuide.Handle
public bool Handle(KeyboardEvent e)

Runs the action of the first listed shortcut that e matches, and answers whether one did - so a caller can stop the event only when the press was taken.

Method
ShortcutGuide.SetTitle
public ShortcutGuide SetTitle(string title)

Sets the title of the component.

Method
ShortcutGuide.Width
public ShortcutGuide Width(UnitSize width)

Sets the width of the component.

Method
ShortcutGuide.W
public ShortcutGuide W(UnitSize width)

Sets the width of the component.

Method
ShortcutGuide.LightDismiss
public ShortcutGuide LightDismiss()

Enables light-dismiss behaviour (clicking outside the guide closes it). It is on by default.

Method
ShortcutGuide.NoLightDismiss
public ShortcutGuide NoLightDismiss()

Removes / disables the light dismiss on the component.

Method
ShortcutGuide.OnShow
public ShortcutGuide OnShow(Modal.OnShowHandler onShow)

Registers a callback invoked when the guide is shown.

Method
ShortcutGuide.OnHide
public ShortcutGuide OnHide(Modal.OnHideHandler onHide)

Registers a callback invoked when the guide is hidden.

Method
ShortcutGuide.Show
public ShortcutGuide Show()

Shows the component.

Method
ShortcutGuide.Hide
public ShortcutGuide Hide(Action onHidden = null)

Hides the component.

Method
ShortcutGuide.Toggle
public ShortcutGuide Toggle()

Shows the guide if it is hidden and hides it if it is shown, which is what the shortcut that opens it usually does.

Method
ShortcutGuide.ShowEmbedded
public IComponent ShowEmbedded()

Returns the guide as a component to place in the page, instead of showing it as a modal layer.

Method
ShortcutGuide.Render
public HTMLElement Render()

Renders the component's root HTML element.

See also

© 2026 Curiosity. All rights reserved.