Alt
18
Alt / Option
event.keyCode
18
event.key
Alt
event.code
AltRight
Unicode
⎇ / ⌥
Code Examples
Copy and paste these examples to detect the Alt key in your JavaScript code
Recommended modern approach
// Modern approach (recommended)
document.addEventListener('keydown', (e) => {
if (e.key === 'Alt') {
console.log('Alt key pressed!');
// Your code here
}
});Common Use Cases
How the Alt key is typically used in web applications
Menu Access
Access application menus and shortcuts
Window Switching
Switch between windows with Alt+Tab
Browser Navigation
Navigate back/forward in browsers with Alt+Arrow
Related Keys
Other keys commonly used together or in similar contexts