keecode logokeecode

Backspace

8

backspace / delete

event.keyCode

8

event.key

Backspace

event.code

Backspace

Unicode

Code Examples

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

Recommended modern approach

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

Common Use Cases

How the Backspace key is typically used in web applications

Delete Text

Remove characters before cursor in text inputs

Browser Back

Navigate back in browser history (default behavior)

Remove Items

Delete selected items in lists and galleries

Related Keys

Other keys commonly used together or in similar contexts