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