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