KeyboardShortcut

Description

Render keyboard shortcuts as styled key chips

KeyboardShortcut renders one or more key names as styled chips that look like physical keyboard keys. It automatically adapts modifier key labels to the current OS (⌘ on macOS, Ctrl on Windows/Linux) and handles special keys like Enter (↵), Escape, and arrow keys.

Samples

Common Shortcuts

Special Keys

Inline Usage

API reference

class

KeyboardShortcut

public sealed class KeyboardShortcut : ComponentBase<KeyboardShortcut, HTMLElement>

Renders a keyboard shortcut as styled <kbd> chips (e.g. Ctrl+K).

Namespace
Tesserae
Inheritance
ComponentBase<KeyboardShortcut, HTMLElement> → KeyboardShortcut

Constructors

NameDescription
KeyboardShortcutInitializes a new instance of this class.
Constructor
KeyboardShortcut
public KeyboardShortcut(params string[] keys)

Initializes a new instance of this class.

Methods

NameDescription
RenderRenders the component's root HTML element.
MatchesWhether e is the shortcut described by keys - the same key names this component displays, so a shortcut can be declared once and what is shown cannot drift from what is bound. Ctrl (and its aliases Mod / CmdOrCtrl) is the platform's command modifier: Ctrl elsewhere, and on Apple either Cmd or Ctrl - which is also why it shows there as ⌘. Use the explicit Control for a shortcut that means the Control key on a Mac too.
Method
KeyboardShortcut.Render
public override HTMLElement Render()

Renders the component's root HTML element.

Method
KeyboardShortcut.Matches
public static bool Matches(KeyboardEvent e, params string[] keys)

Whether e is the shortcut described by keys - the same key names this component displays, so a shortcut can be declared once and what is shown cannot drift from what is bound. Ctrl (and its aliases Mod / CmdOrCtrl) is the platform's command modifier: Ctrl elsewhere, and on Apple either Cmd or Ctrl - which is also why it shows there as ⌘. Use the explicit Control for a shortcut that means the Control key on a Mac too.

See also

© 2026 Curiosity. All rights reserved.