keecode logokeecode

²

50

sqaure

event.keyCode

50

event.key

²

event.code

Digit2

Unicode

²

Code Examples

Copy and paste these examples to detect the ² key in your JavaScript code

Recommended modern approach

// Modern approach (recommended)
document.addEventListener('keydown', (e) => {
  if (e.key === '²') {
    console.log('² key pressed!');
    // Your code here
  }
});

Related Keys

Other keys commonly used together or in similar contexts