Keyboard markup

You can represent keyboard keys and shortcuts in your documentation using the {kbd} role. This is useful for showing keyboard commands and shortcuts in a visually consistent way. See the full list of available keys.

To display a keyboard key, use the syntax {kbd}`key-name`. For example, writing {kbd}`enter` will render as a styled keyboard key.

Press ↵Enter to submit.

Press {kbd}`enter` to submit.
		

For keyboard shortcuts involving multiple keys, you can combine them within a single {kbd} role by separating the key names with a +. Keys are always visually separated, even when using the combined syntax.

Use ⌘Cmd + ⇧Shift + ↵Enter to execute the command.

Use {kbd}`cmd+shift+enter` to execute the command.
		

To display alternative keys for a shortcut, use | to separate the alternate keys within the same {kbd} role. This is useful for showing platform-specific shortcuts, such as ctrl on Windows and cmd on macOS.

Use ⌃Ctrl⌘Cmd + c to copy text.

Use {kbd}`ctrl|cmd + c` to copy text.
		

The + and | characters have special meaning for combining keys and specifying alternatives. To render them as literal keys, you must use their keyword equivalents.

  • To display the + key, use `{kbd}`plus`.
  • To display the | key, use `{kbd}`pipe`.

The platform-specific examples below demonstrate how to combine special keys and regular characters.

Mac Windows/Linux Description
⌘Cmd + c ⌃Ctrl + c Copy
⌘Cmd + v ⌃Ctrl + v Paste
⌘Cmd + z ⌃Ctrl + z Undo
⌘Cmd + ↵Enter ⌃Ctrl + ↵Enter Run a query
⌘Cmd + / ⌃Ctrl + / Comment or uncomment a line
| Mac              | Windows/Linux     | Description                 |
|------------------|-------------------|-----------------------------|
| {kbd}`cmd+c`     | {kbd}`ctrl+c`     | Copy                        |
| {kbd}`cmd+v`     | {kbd}`ctrl+v`     | Paste                       |
| {kbd}`cmd+z`     | {kbd}`ctrl+z`     | Undo                        |
| {kbd}`cmd+enter` | {kbd}`ctrl+enter` | Run a query                 |
| {kbd}`cmd+/`     | {kbd}`ctrl+/`     | Comment or uncomment a line |
		

The {kbd} role recognizes a set of special keywords for modifier, navigation, and function keys. Any other text will be rendered as a literal key.

Here is the full list of available keywords:

Syntax Rendered Output
{kbd}`shift` ⇧Shift
{kbd}`ctrl` ⌃Ctrl
{kbd}`alt` ⌥Alt
{kbd}`option` ⌥Opt
{kbd}`cmd` ⌘Cmd
{kbd}`win` ⊞Win
{kbd}`up` ↑Up
{kbd}`down` ↓Down
{kbd}`left` ←Left
{kbd}`right` →Right
{kbd}`space` ␣Space
{kbd}`tab` ↹Tab
{kbd}`enter` ↵Enter
{kbd}`esc` ⎋Esc
{kbd}`backspace` ⌫Backspace
{kbd}`del` Del
{kbd}`ins` Ins
{kbd}`pageup` ⇞PageUp
{kbd}`pagedown` ⇟PageDown
{kbd}`home` ⇱Home
{kbd}`end` ⇲End
{kbd}`f1` F1
{kbd}`f2` F2
{kbd}`f3` F3
{kbd}`f4` F4
{kbd}`f5` F5
{kbd}`f6` F6
{kbd}`f7` F7
{kbd}`f8` F8
{kbd}`f9` F9
{kbd}`f10` F10
{kbd}`f11` F11
{kbd}`f12` F12
{kbd}`plus` +
{kbd}`fn` Fn
{kbd}`pipe` |