Computer scienceProgramming languagesJavaScriptInteraction with a browserDOM Events

Keyboard events handling

Numeric key codes

Report a typo

What do you need to write in parentheses to activate the event handler after pressing the key 2?

document.addEventListener("keydown", function(e) {
  if (...) {
    console.log(e);
  }
});

Write only the missing part.

Enter a short text
___

Create a free account to access the full topic