UI Components Easy
Keyboard Display
Keyboard shortcut display component with individual key caps — single keys, combinations (⌘K), and a shortcut list table.
Open in Lab
MCP
css
Targets: HTML
Code
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Inter, system-ui, sans-serif;
background: #050910;
color: #f2f6ff;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
}
.demo {
width: 100%;
max-width: 600px;
}
.demo-title {
font-size: 1.5rem;
font-weight: 800;
margin-bottom: 0.375rem;
}
.demo-sub {
color: #475569;
font-size: 0.875rem;
margin-bottom: 2rem;
}
.section {
margin-bottom: 1.75rem;
}
.section-label {
font-size: 0.72rem;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #475569;
margin-bottom: 0.75rem;
}
.row {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
}
/* ── Key cap ── */
kbd {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 2rem;
height: 2rem;
padding: 0 0.5rem;
border-radius: 6px;
font-family: inherit;
font-size: 0.8rem;
font-weight: 600;
line-height: 1;
white-space: nowrap;
background: #0e1624;
color: #cbd5e1;
border: 1px solid #1e293b;
box-shadow: 0 1px 0 0 #334155, 0 2px 0 0 rgba(0, 0, 0, 0.6), inset 0 1px 0
rgba(255, 255, 255, 0.06);
user-select: none;
cursor: default;
}
/* ── Combo wrapper ── */
.kbd-combo {
display: inline-flex;
align-items: center;
gap: 0.2rem;
}
.kbd-sep {
font-size: 0.65rem;
color: #475569;
font-weight: 600;
line-height: 1;
padding: 0 0.05rem;
}
/* ── Shortcut table ── */
.shortcut-table {
width: 100%;
border-collapse: collapse;
}
.shortcut-table tr {
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.shortcut-table tr:last-child {
border-bottom: none;
}
.shortcut-table th,
.shortcut-table td {
padding: 0.7rem 0.5rem;
text-align: left;
vertical-align: middle;
}
.shortcut-table th {
font-size: 0.85rem;
font-weight: 500;
color: #94a3b8;
width: 100%;
}
.shortcut-table td {
white-space: nowrap;
text-align: right;
}<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Keyboard Display</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="demo">
<h1 class="demo-title">Keyboard Display</h1>
<p class="demo-sub">Key caps, combos, and shortcut cheat sheet.</p>
<section class="section">
<p class="section-label">Single keys</p>
<div class="row">
<kbd>⌘</kbd>
<kbd>⌃</kbd>
<kbd>⌥</kbd>
<kbd>⇧</kbd>
<kbd>Tab</kbd>
<kbd>Esc</kbd>
<kbd>↵</kbd>
<kbd>⌫</kbd>
<kbd>Space</kbd>
</div>
</section>
<section class="section">
<p class="section-label">Combinations</p>
<div class="row">
<span class="kbd-combo" aria-label="Command K">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>K</kbd>
</span>
<span class="kbd-combo" aria-label="Command Shift P">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>⇧</kbd><span class="kbd-sep">+</span><kbd>P</kbd>
</span>
<span class="kbd-combo" aria-label="Control Alt Delete">
<kbd>⌃</kbd><span class="kbd-sep">+</span><kbd>⌥</kbd><span class="kbd-sep">+</span><kbd>Del</kbd>
</span>
<span class="kbd-combo" aria-label="Command Z">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>Z</kbd>
</span>
</div>
</section>
<section class="section">
<p class="section-label">Shortcut cheat sheet</p>
<table class="shortcut-table" role="grid">
<tbody>
<tr>
<th scope="row">Command palette</th>
<td>
<span class="kbd-combo" aria-label="Command Shift P">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>⇧</kbd><span class="kbd-sep">+</span><kbd>P</kbd>
</span>
</td>
</tr>
<tr>
<th scope="row">Quick open file</th>
<td>
<span class="kbd-combo" aria-label="Command P">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>P</kbd>
</span>
</td>
</tr>
<tr>
<th scope="row">Find in files</th>
<td>
<span class="kbd-combo" aria-label="Command Shift F">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>⇧</kbd><span class="kbd-sep">+</span><kbd>F</kbd>
</span>
</td>
</tr>
<tr>
<th scope="row">Toggle terminal</th>
<td>
<span class="kbd-combo" aria-label="Control backtick">
<kbd>⌃</kbd><span class="kbd-sep">+</span><kbd>`</kbd>
</span>
</td>
</tr>
<tr>
<th scope="row">Save file</th>
<td>
<span class="kbd-combo" aria-label="Command S">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>S</kbd>
</span>
</td>
</tr>
<tr>
<th scope="row">Undo</th>
<td>
<span class="kbd-combo" aria-label="Command Z">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>Z</kbd>
</span>
</td>
</tr>
<tr>
<th scope="row">Redo</th>
<td>
<span class="kbd-combo" aria-label="Command Shift Z">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>⇧</kbd><span class="kbd-sep">+</span><kbd>Z</kbd>
</span>
</td>
</tr>
<tr>
<th scope="row">Select all</th>
<td>
<span class="kbd-combo" aria-label="Command A">
<kbd>⌘</kbd><span class="kbd-sep">+</span><kbd>A</kbd>
</span>
</td>
</tr>
</tbody>
</table>
</section>
</div>
</body>
</html>Keyboard Display
Styled <kbd> elements for presenting keyboard shortcuts and hotkeys.
Variants
- Single key — standalone key cap with pressed-key bevel shadow
- Combo — multiple keys joined with
+separator - Shortcut table — labeled list of shortcuts for cheat sheets
Usage
Wrap individual keys in <kbd> and group combinations with a <span class="kbd-combo"> container. The table variant uses standard <table> semantics with scope="row" for accessibility.