|
| 1 | +# Keyboard shortcuts |
| 2 | + |
| 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 | + |
| 5 | +## Basic usage |
| 6 | + |
| 7 | +To display a keyboard key, use the syntax `` {kbd}`key-name` ``. For example, writing `` {kbd}`enter` `` will render as a styled keyboard key. |
| 8 | + |
| 9 | +::::{tab-set} |
| 10 | + |
| 11 | +:::{tab-item} Output |
| 12 | +Press {kbd}`enter` to submit. |
| 13 | +::: |
| 14 | + |
| 15 | +:::{tab-item} Markdown |
| 16 | +```markdown |
| 17 | +Press {kbd}`enter` to submit. |
| 18 | +``` |
| 19 | +::: |
| 20 | + |
| 21 | +:::: |
| 22 | + |
| 23 | +## Combining keys |
| 24 | + |
| 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 | + |
| 27 | +::::{tab-set} |
| 28 | + |
| 29 | +:::{tab-item} Output |
| 30 | +Use {kbd}`cmd+shift+enter` to execute the command. |
| 31 | +::: |
| 32 | + |
| 33 | +:::{tab-item} Markdown |
| 34 | +```markdown |
| 35 | +Use {kbd}`cmd+shift+enter` to execute the command. |
| 36 | +``` |
| 37 | +::: |
| 38 | + |
| 39 | +:::: |
| 40 | + |
| 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. |
| 44 | + |
| 45 | +::::{tab-set} |
| 46 | + |
| 47 | +:::{tab-item} Output |
| 48 | +Use {kbd}`ctrl|cmd + c` to copy text. |
| 49 | +::: |
| 50 | + |
| 51 | +:::{tab-item} Markdown |
| 52 | +```markdown |
| 53 | +Use {kbd}`ctrl|cmd + c` to copy text. |
| 54 | +``` |
| 55 | +::: |
| 56 | + |
| 57 | +:::: |
| 58 | + |
| 59 | +## Reserved characters |
| 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. |
| 62 | + |
| 63 | +- To display the {kbd}`plus` key, use `` `{kbd}`plus` ``. |
| 64 | +- To display the {kbd}`pipe` key, use `` `{kbd}`pipe` ``. |
| 65 | + |
| 66 | +## Common shortcuts by platform |
| 67 | + |
| 68 | +The platform-specific examples below demonstrate how to combine special keys and regular characters. |
| 69 | + |
| 70 | +::::{tab-set} |
| 71 | + |
| 72 | +:::{tab-item} Output |
| 73 | + |
| 74 | +| Mac | Windows/Linux | Description | |
| 75 | +|------------------|-------------------|-----------------------------| |
| 76 | +| {kbd}`cmd+c` | {kbd}`ctrl+c` | Copy | |
| 77 | +| {kbd}`cmd+v` | {kbd}`ctrl+v` | Paste | |
| 78 | +| {kbd}`cmd+z` | {kbd}`ctrl+z` | Undo | |
| 79 | +| {kbd}`cmd+enter` | {kbd}`ctrl+enter` | Run a query | |
| 80 | +| {kbd}`cmd+/` | {kbd}`ctrl+/` | Comment or uncomment a line | |
| 81 | + |
| 82 | +::: |
| 83 | + |
| 84 | +:::{tab-item} Markdown |
| 85 | +```markdown |
| 86 | +| Mac | Windows/Linux | Description | |
| 87 | +|------------------|-------------------|-----------------------------| |
| 88 | +| {kbd}`cmd+c` | {kbd}`ctrl+c` | Copy | |
| 89 | +| {kbd}`cmd+v` | {kbd}`ctrl+v` | Paste | |
| 90 | +| {kbd}`cmd+z` | {kbd}`ctrl+z` | Undo | |
| 91 | +| {kbd}`cmd+enter` | {kbd}`ctrl+enter` | Run a query | |
| 92 | +| {kbd}`cmd+/` | {kbd}`ctrl+/` | Comment or uncomment a line | |
| 93 | +``` |
| 94 | +::: |
| 95 | + |
| 96 | +:::: |
| 97 | + |
| 98 | +## Available keys |
| 99 | + |
| 100 | +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. |
| 101 | + |
| 102 | +Here is the full list of available keywords: |
| 103 | + |
| 104 | +| Syntax | Rendered Output | |
| 105 | +|-------------------------|------------------| |
| 106 | +| `` {kbd}`shift` `` | {kbd}`shift` | |
| 107 | +| `` {kbd}`ctrl` `` | {kbd}`ctrl` | |
| 108 | +| `` {kbd}`alt` `` | {kbd}`alt` | |
| 109 | +| `` {kbd}`option` `` | {kbd}`option` | |
| 110 | +| `` {kbd}`cmd` `` | {kbd}`cmd` | |
| 111 | +| `` {kbd}`win` `` | {kbd}`win` | |
| 112 | +| `` {kbd}`up` `` | {kbd}`up` | |
| 113 | +| `` {kbd}`down` `` | {kbd}`down` | |
| 114 | +| `` {kbd}`left` `` | {kbd}`left` | |
| 115 | +| `` {kbd}`right` `` | {kbd}`right` | |
| 116 | +| `` {kbd}`space` `` | {kbd}`space` | |
| 117 | +| `` {kbd}`tab` `` | {kbd}`tab` | |
| 118 | +| `` {kbd}`enter` `` | {kbd}`enter` | |
| 119 | +| `` {kbd}`esc` `` | {kbd}`esc` | |
| 120 | +| `` {kbd}`backspace` `` | {kbd}`backspace` | |
| 121 | +| `` {kbd}`del` `` | {kbd}`delete` | |
| 122 | +| `` {kbd}`ins` `` | {kbd}`insert` | |
| 123 | +| `` {kbd}`pageup` `` | {kbd}`pageup` | |
| 124 | +| `` {kbd}`pagedown` `` | {kbd}`pagedown` | |
| 125 | +| `` {kbd}`home` `` | {kbd}`home` | |
| 126 | +| `` {kbd}`end` `` | {kbd}`end` | |
| 127 | +| `` {kbd}`f1` `` | {kbd}`f1` | |
| 128 | +| `` {kbd}`f2` `` | {kbd}`f2` | |
| 129 | +| `` {kbd}`f3` `` | {kbd}`f3` | |
| 130 | +| `` {kbd}`f4` `` | {kbd}`f4` | |
| 131 | +| `` {kbd}`f5` `` | {kbd}`f5` | |
| 132 | +| `` {kbd}`f6` `` | {kbd}`f6` | |
| 133 | +| `` {kbd}`f7` `` | {kbd}`f7` | |
| 134 | +| `` {kbd}`f8` `` | {kbd}`f8` | |
| 135 | +| `` {kbd}`f9` `` | {kbd}`f9` | |
| 136 | +| `` {kbd}`f10` `` | {kbd}`f10` | |
| 137 | +| `` {kbd}`f11` `` | {kbd}`f11` | |
| 138 | +| `` {kbd}`f12` `` | {kbd}`f12` | |
| 139 | +| `` {kbd}`plus` `` | {kbd}`plus` | |
| 140 | +| `` {kbd}`fn` `` | {kbd}`fn` | |
| 141 | +| `` {kbd}`pipe` `` | {kbd}`pipe` | |
0 commit comments