Srinabh
Srinabh

Reputation: 400

Uncaught TypeError: Window.addEventListener is not a function

I tried to add an event listener on the DOM Window, however, it suggests that Window.addEventListener is not a function.

<script>
  Window.addEventListener('keydown',function (e){
    console.log(e);
  });
</script>

I expected the console to log the keydown event.

Upvotes: 1

Views: 4812

Answers (1)

niklas
niklas

Reputation: 3011

You have a typo. It must be

//small 'w'
window.addEventListener('keydown',function (e){
  console.log(e);
});

Upvotes: 3

Related Questions