Inline
HTML 2.0
The keyboard input element represents user input from a keyboard, voice input, or any other text entry device. It’s typically displayed in a monospace font.
Interactive code playground requires JavaScript. Here's the code:
<p>Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to copy and <kbd>Ctrl</kbd>+<kbd>V</kbd> to paste.</p>
< kbd > keyboard input </ kbd >
The <kbd> element represents text that the user should type or input.
Interactive code playground requires JavaScript. Here's the code:
<p>Press <kbd>Ctrl</kbd>+<kbd>S</kbd> to save your work.</p>
<p>Use <kbd>Ctrl</kbd>+<kbd>Z</kbd> to undo and <kbd>Ctrl</kbd>+<kbd>Y</kbd> to redo.</p>
Interactive code playground requires JavaScript. Here's the code:
<p>Press <kbd>Enter</kbd> to submit the form.</p>
<p>Hit <kbd>Esc</kbd> to close the dialog.</p>
<p>Press <kbd>F11</kbd> for fullscreen mode.</p>
Interactive code playground requires JavaScript. Here's the code:
<p>Type <kbd>npm install</kbd> to install dependencies.</p>
<p>Run <kbd>git status</kbd> to check repository status.</p>
Interactive code playground requires JavaScript. Here's the code:
<p>Type <kbd>yes</kbd> to confirm or <kbd>no</kbd> to cancel.</p>
<p>Enter <kbd>admin</kbd> as the username.</p>
Interactive code playground requires JavaScript. Here's the code:
<p>Navigate using arrow keys: <kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> <kbd>→</kbd></p>
<p>Press <kbd>Tab</kbd> to move to the next field.</p>
Interactive code playground requires JavaScript. Here's the code:
<ul>
<li><kbd>F1</kbd> - Help</li>
<li><kbd>F5</kbd> - Refresh</li>
<li><kbd>F12</kbd> - Developer tools</li>
</ul>
Interactive code playground requires JavaScript. Here's the code:
<p>Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd> to reopen closed tab.</p>
<p>Use <kbd>Cmd</kbd>+<kbd>Option</kbd>+<kbd>Esc</kbd> on Mac to force quit.</p>
Interactive code playground requires JavaScript. Here's the code:
<p>First press <kbd>Alt</kbd>, then <kbd>F</kbd>, then <kbd>O</kbd> to open File menu.</p>
You can nest <kbd> elements to show key combinations:
Interactive code playground requires JavaScript. Here's the code:
<p>Save: <kbd><kbd>Ctrl</kbd>+<kbd>S</kbd></kbd></p>
<p>Copy: <kbd><kbd>Ctrl</kbd>+<kbd>C</kbd></kbd></p>
<!-- User keyboard/input -->
< p > Press < kbd > Enter </ kbd > to continue. </ p >
< p > Use the < code > console.log() </ code > function. </ p >
< p > Output: < samp > Process complete </ samp ></ p >
< p > The value of < var > x </ var > is 10. </ p >
Customize keyboard input appearance:
Interactive code playground requires JavaScript. Here's the code:
<style>
kbd {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 3px;
box-shadow: 0 1px 0 rgba(0,0,0,0.2);
padding: 2px 6px;
font-family: monospace;
font-size: 0.9em;
}
</style>
<p>Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to copy.</p>
Interactive code playground requires JavaScript. Here's the code:
<style>
.mac kbd { font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.windows kbd { font-family: 'Segoe UI', Tahoma, sans-serif; }
</style>
<div class="mac">
<p>Mac: <kbd>⌘</kbd>+<kbd>C</kbd> to copy</p>
</div>
<div class="windows">
<p>Windows: <kbd>Ctrl</kbd>+<kbd>C</kbd> to copy</p>
</div>
Interactive code playground requires JavaScript. Here's the code:
<style>
.key-button kbd {
display: inline-block;
background: linear-gradient(to bottom, #f9f9f9, #e3e3e3);
border: 1px solid #aaa;
border-radius: 4px;
padding: 4px 8px;
margin: 0 2px;
font-weight: 600;
box-shadow: 0 2px 0 #bbb, 0 3px 2px rgba(0,0,0,0.2);
}
.key-button kbd:active {
box-shadow: 0 1px 0 #bbb;
transform: translateY(2px);
}
</style>
<div class="key-button">
<p>Press <kbd>Space</kbd> to jump.</p>
</div>
Interactive code playground requires JavaScript. Here's the code:
<table>
<tr>
<th>Action</th>
<th>Shortcut</th>
</tr>
<tr>
<td>Save</td>
<td><kbd>Ctrl</kbd>+<kbd>S</kbd></td>
</tr>
<tr>
<td>Print</td>
<td><kbd>Ctrl</kbd>+<kbd>P</kbd></td>
</tr>
<tr>
<td>Find</td>
<td><kbd>Ctrl</kbd>+<kbd>F</kbd></td>
</tr>
</table>
Interactive code playground requires JavaScript. Here's the code:
<ol>
<li>Open Terminal</li>
<li>Type <kbd>cd ~/projects</kbd> and press <kbd>Enter</kbd></li>
<li>Run <kbd>npm init</kbd> to create a new project</li>
<li>Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to exit when done</li>
</ol>
Interactive code playground requires JavaScript. Here's the code:
<h4>Game Controls</h4>
<ul>
<li><kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd> - Move</li>
<li><kbd>Space</kbd> - Jump</li>
<li><kbd>E</kbd> - Interact</li>
<li><kbd>Esc</kbd> - Pause menu</li>
</ul>
Interactive code playground requires JavaScript. Here's the code:
<section>
<h4>Quick Tips</h4>
<dl>
<dt>Zoom in</dt>
<dd><kbd>Ctrl</kbd>+<kbd>+</kbd></dd>
<dt>Zoom out</dt>
<dd><kbd>Ctrl</kbd>+<kbd>-</kbd></dd>
<dt>Reset zoom</dt>
<dd><kbd>Ctrl</kbd>+<kbd>0</kbd></dd>
</dl>
</section>
Combine with <samp> to show command and output:
Interactive code playground requires JavaScript. Here's the code:
<p>Command: <kbd>whoami</kbd></p>
<p>Output: <samp>username</samp></p>
<p>Command: <kbd>pwd</kbd></p>
<p>Output: <samp>/home/user/documents</samp></p>
Screen readers may announce <kbd> content as keyboard input, helping users understand they should type this text.
< p > Hit the key to save. </ p >
< p > Press < kbd > Ctrl </ kbd > + < kbd > S </ kbd > to save your document. </ p >
Provide alternatives for different operating systems:
< kbd > Ctrl </ kbd > + < kbd > S </ kbd > (Windows/Linux)
or < kbd > ⌘ </ kbd > + < kbd > S </ kbd > (Mac)
Browser Version Notes Chrome 1+ Full support Firefox 1+ Full support Safari 1+ Full support Edge 12+ Full support IE 3+ Full support
The <kbd> element has been supported since the earliest browsers.