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