You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
3
+
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](#available-keys).
4
4
5
5
## Basic usage
6
6
@@ -22,7 +22,7 @@ Press {kbd}`enter` to submit.
22
22
23
23
## Combining keys
24
24
25
-
For keyboard shortcuts involving multiple keys, you can combine them within a single `{kbd}` role by separating the key names with a `+`.
25
+
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.
26
26
27
27
::::{tab-set}
28
28
@@ -38,36 +38,30 @@ Use {kbd}`cmd+shift+enter` to execute the command.
38
38
39
39
::::
40
40
41
-
Alternatively, you can use multiple `{kbd}` roles to describe a shortcut. This approach is useful when you want to visually separate keys. Use a `+` to represent a combination and a `/` to represent alternative keys.
41
+
## Alternative keys
42
+
43
+
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.
42
44
43
45
::::{tab-set}
44
46
45
47
:::{tab-item} Output
46
-
{kbd}`ctrl` + {kbd}`c` to copy text, or {kbd}`cmd` + {kbd}`c` on Mac.
48
+
Use {kbd}`ctrl|cmd + c` to copy text.
47
49
:::
48
50
49
51
:::{tab-item} Markdown
50
52
```markdown
51
-
{kbd}`ctrl` + {kbd}`c` to copy text, or {kbd}`cmd` + {kbd}`c` on Mac.
53
+
Use {kbd}`ctrl|cmd + c` to copy text.
52
54
```
53
55
:::
54
56
55
57
::::
56
58
57
-
::::{tab-set}
58
-
59
-
:::{tab-item} Output
60
-
{kbd}`ctrl` / {kbd}`cmd` + {kbd}`c` to copy text.
61
-
:::
59
+
## Reserved characters
62
60
61
+
The `+` and `|` characters have special meaning for combining keys and specifying alternatives. To render them as literal keys, you must use their keyword equivalents.
63
62
64
-
:::{tab-item} Markdown
65
-
```markdown
66
-
{kbd}`ctrl` / {kbd}`cmd` + {kbd}`c` to copy text.
67
-
```
68
-
:::
69
-
70
-
::::
63
+
- To display the {kbd}`plus` key, use `` `{kbd}`plus` ``.
64
+
- To display the {kbd}`pipe` key, use `` `{kbd}`pipe` ``.
71
65
72
66
## Common shortcuts by platform
73
67
@@ -107,40 +101,41 @@ The `{kbd}` role recognizes a set of special keywords for modifier, navigation,
0 commit comments