Skip to content
All components

Components

Keyboard shortcut

A shortcut is a key and the modifiers held with it. Shortcut::parse reads "cmd+shift+k", "ctrl+k" or "alt+enter" in any case, and gives None for an unknown modifier, an empty string or a chord with no key. The label writes the modifiers in Apple's order ⌃⌥⇧⌘ and then the key, with signs for named keys such as ↩ for enter and ⎋ for escape.

Chords

Parsed from text, drawn with the Mac's symbols.

⌘K⇧⌘P⌥↩
for k in ["cmd+k", "shift+cmd+p", "alt+enter"].into_iter().filter_map(Shortcut::parse) {
    k.html(out);,
}

Single keys

A key alone, such as the slash that opens search.

/⎋↩
for k in ["/", "esc", "enter"].into_iter().filter_map(Shortcut::parse) {
    k.html(out);,
}

In a sentence

Shortcuts read inline with the words around them.

Press⌘Kto search.
out.push_str("<span>Press</span>");
if let Some(k) = Shortcut::parse("cmd+k") { k.html(out); } out.push_str("<span>to search.</span>");

On the Mac

The same vocabulary drawn by Ocean UI's native face (egui on Metal), as the gallery's snapshot.

Keyboard shortcut drawn by Ocean UI's native face, darkKeyboard shortcut drawn by Ocean UI's native face, light

Use it

Web

use ocean_ui_core::Shortcut;
Shortcut::parse("cmd+k")

Native

use ocean_ui_native::{Show, core::Shortcut, widgets::Kbd};
if let Some(chord) = Shortcut::parse("cmd+shift+k") { Kbd(chord).show(ui); }

Cargo feature base of ocean-ui-core, ocean-ui-web and ocean-ui-native; available since 2026-10-29.

Props

NameTypeDefaultWhat
keyString—The key in lowercase, such as k, enter, escape, /, f2 or up.
cmdbool—Command (⌘) is held.
shiftbool—Shift (⇧) is held.
altbool—Option (⌥) is held.
ctrlbool—Control (⌃) is held.

Accessibility

  • The chord is text in one kbd element, so a screen reader reads its signs in order.
  • It is not a control; it takes no focus and does nothing when clicked.
  • Name the action in words beside it, since the signs alone say only which keys to press.

Related

Markdown

The same page as Markdown, for an agent or a pull request.

Search

esc

Components

Blocks

Screens built from blocks

The Ocean app

Ocean Base console