Shortcut Syntax
Starlight Kbd supports a simple syntax for documenting keyboard shortcuts.
This guide describes the format supported by the <Kbd> component and recommended practices.
Shortcuts
A basic shortcut consists of one or more modifier keys followed by a regular key, all connected with + signs.
A shortcut with a single modifier key:
<Kbd mac="Command+S" windows="Control+S" />
A shortcut with multiple modifier keys:
<Kbd mac="Command+Shift+S" windows="Control+Shift+S" />A shortcut with a single modifier key:
A shortcut with multiple modifier keys:
Chords
Some commands require a sequence of keyboard combinations, also known as chords. These are represented by separating each combination with a space.
Press some keys and then press some more keys:
<Kbd mac="Command+K Command+S" windows="Control+K Control+S" />Press some keys and then press some more keys:
Recommendations
When documenting keyboard shortcuts, consider these recommendations:
-
Be consistent and use the same key names throughout your documentation. For example, stick to either
ControlorCtrlbut not both. -
Avoid glyphs and use text for modifier keys. For example, use
Commandinstead of⌘which may not be obvious to all users.