Tab
9
tab
event.keyCode
9
event.key
Tab
event.code
Tab
Unicode
↹
Code Examples
Copy and paste these examples to detect the Tab key in your JavaScript code
Recommended modern approach
// Modern approach (recommended)
document.addEventListener('keydown', (e) => {
if (e.key === 'Tab') {
console.log('Tab key pressed!');
// Your code here
}
});Common Use Cases
How the Tab key is typically used in web applications
Form Navigation
Move focus between form inputs and buttons
Accessibility Navigation
Navigate through focusable elements for keyboard users
Code Indentation
Add indentation in code editors and text areas
Related Keys
Other keys commonly used together or in similar contexts