# Keybinding hint

> A muted “Open file Ctrl P” hint. A native Pyzed component for Python desktop GUIs, with a live preview, code examples and its API.

Source: https://albakore.github.io/pyzed/library/keybinding-hint/

:::tip[In plain words]
A quiet line that teaches a shortcut: “Open file  Ctrl P”.
:::

A muted hint that pairs an action with its shortcut, for footers and empty states.

`ui.keybinding_hint` · Category: [Feedback](https://albakore.github.io/pyzed/library/#feedback) · [Full reference →](https://albakore.github.io/pyzed/reference/ui/#keybinding_hint)

**Code:**

```python
pz.column([
    ui.keybinding_hint("Open file", "ctrl-p"),
    ui.keybinding_hint("Command palette", "ctrl-shift-p"),
    ui.keybinding_hint("Toggle terminal", "ctrl-j"),
], spacing=10, align="center")
```

## When to use

- In empty editors and footers, to teach the shortcuts of the most useful actions.

## Usage

```python
import pyzed as pz
from pyzed import ui

pz.column([
    ui.keybinding_hint("Open file", "ctrl-p"),
    ui.keybinding_hint("Command palette", "ctrl-shift-p"),
    ui.keybinding_hint("Toggle terminal", "ctrl-j"),
], spacing=10, align="center")
```

## Variants

:::note[About these captures]
Each capture is recorded by pyzed itself, off-screen at 2x, in One Dark or One Light to match this site's theme, and cropped to the component so it shows at its real size. The pointer hovers, presses or types into it; a component that does not react to the pointer cycles through a few themes. With reduced motion you see the first frame. Open **Code** under a capture to see the snippet that draws it; free names such as `on_save` stand for your own callbacks.
:::

### Examples

```python
ui.keybinding_hint("Search", "/")
```

```python
ui.keybinding_hint("Command palette", "ctrl-shift-p")
```

```python
ui.keybinding_hint("Keyboard shortcuts", "ctrl-k ctrl-s")
```

## Events

Keybinding hint 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](https://albakore.github.io/pyzed/guides/events/) and [Events of every component](https://albakore.github.io/pyzed/library/events/).

## Properties and API

### `ui.keybinding_hint`

```python
keybinding_hint(text, keys, *, theme=None)
```

A muted hint like “Open file Ctrl P” for footers and empty states.

| Property | Default | Description |
| --- | --- | --- |
| `text` | *required* | Text. |
| `keys` | *required* | Shortcut shown at the end, written as a string: `"ctrl-s"`, `"cmd-k cmd-s"`. |
| `theme` | `None` | Theme to use instead of the current one (`pyzed.theme.current()`). |

[Full reference →](https://albakore.github.io/pyzed/reference/ui/#keybinding_hint)

## Related

- [Kbd](https://albakore.github.io/pyzed/library/kbd/): Keyboard shortcuts drawn as keys, with symbols on macOS.
- [Empty state](https://albakore.github.io/pyzed/library/empty-state/): A centered placeholder for empty lists and searches.
- [Shortcuts](https://albakore.github.io/pyzed/library/shortcuts/): A searchable list of key bindings, grouped.
