Kbd
Draws a shortcut written as a string ("ctrl-shift-p", chords like "cmd-k cmd-s") as key caps. On macOS it uses symbols (⌘⇧P) and words elsewhere; pyzed.ui.base.KEY_STYLE forces "symbols" or "words". ui.format_keys returns the labels if you draw them yourself.
ui.kbd · Category: Display · Full reference →


pz.column([ ui.kbd("ctrl-shift-p"), ui.kbd("ctrl-k ctrl-s"), pz.row([ui.kbd("escape", size="xs"), ui.kbd("enter", size="xs"), ui.kbd("tab", size="xs")], spacing=8),], spacing=12, align="center")When to use
Section titled “When to use”- In menus, tooltips, palettes and help screens, to teach shortcuts.
- Most components already accept
keys=and draw it for you (button, menu item, tooltip).
import pyzed as pzfrom pyzed import ui
pz.column([ ui.kbd("ctrl-shift-p"), ui.kbd("ctrl-k ctrl-s"), pz.row([ui.kbd("escape", size="xs"), ui.kbd("enter", size="xs"), ui.kbd("tab", size="xs")], spacing=8),], spacing=12, align="center")Variants
Section titled “Variants”Write shortcuts as "ctrl-s"; on macOS ctrl becomes ⌃ and cmd ⌘ automatically.


Code
ui.kbd("enter")

Code
ui.kbd("ctrl-shift-p")

Code
ui.kbd("ctrl-k ctrl-s")

Code
pz.row([ui.kbd("escape"), ui.kbd("tab"), ui.kbd("backspace"), ui.kbd("up")], spacing=6)

size="xs"Code
ui.kbd("ctrl-p", size="xs")

size="sm"Code
ui.kbd("ctrl-p", size="sm")Events
Section titled “Events”Kbd has no events of its own: it shows what you give it. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.
Properties and API
Section titled “Properties and API”ui.kbd
Section titled “ui.kbd”kbd(keys, *, size='sm', theme=None)Draws a shortcut as keys: "ctrl-shift-p", "cmd-k cmd-s". Uses symbols on macOS (⌘⇧P) and words elsewhere.
| Property | Default | Description |
|---|---|---|
keys |
required | The shortcut. |
size |
"sm" |
"xs" or "sm". |
theme |
None |
Theme to use instead of the current one (pyzed.theme.current()). |
ui.format_keys
Section titled “ui.format_keys”format_keys(keys)Splits a shortcut into labels per chord: format_keys("ctrl-shift-p") == [["Ctrl", "Shift", "P"]]. The style is controlled by pyzed.ui.base.KEY_STYLE ("auto", "symbols" or "words").
| Property | Default | Description |
|---|---|---|
keys |
required | The shortcut. |
ui.keys_text
Section titled “ui.keys_text”keys_text(keys)A shortcut as plain text for a label or a status line: keys_text("ctrl-shift-p") == "Ctrl+Shift+P" ("⌃⇧P" with macOS symbols), chords separated by a space. Tooltips, buttons and menus take keys= instead and draw key caps, so never write the keys into their text.
| Property | Default | Description |
|---|---|---|
keys |
required | The shortcut. |