F1
112
f1
event.keyCode
112
event.key
F1
event.code
F1
Unicode
n/a
Code Examples
Copy and paste these examples to detect the F1 key in your JavaScript code
Recommended modern approach
// Modern approach (recommended)
document.addEventListener('keydown', (e) => {
if (e.key === 'F1') {
console.log('F1 key pressed!');
// Your code here
}
});Related Keys
Other keys commonly used together or in similar contexts