0

This is started happening recently on my project, so I created a fresh project using vue cli 2. I have not added any this else

In App.vue I have added 3 event listeners in mounted function.

window.addEventListener("keydown", () => {
    console.log("Key down");
})
window.addEventListener('keyup', () => {
    console.log("Key up");
})
window.addEventListener("keypress", () => {
    console.log("Key press");
})

This above code prints all the events on Firefox and Safari, but not in chrome. It also works in chrome incognito but not in normal mode.

Also this is only happening on mac machine.

Also this only occurs when I am using vue

If i create a standalone html file the code return all the 3 events.

Any debugging idea is also appreciated.

Vaibhav Singh
  • 421
  • 3
  • 12
  • When are you registering these events?. You should register them while `created` event not on `mounted`. – junaid rasheed Feb 25 '20 at 06:05
  • I tried registering the events in created function , it still doesn't work, It is quite obvious that something has went wrong with my machine only but i have no idea what it is. – Vaibhav Singh Feb 25 '20 at 06:21
  • Can you share a codepen or fiddle of your code?. Also test it on someone else's machine. Maybe its version issue of the browser. – junaid rasheed Feb 25 '20 at 07:18
  • Its working on codepens and fiddle , its just not working on my mac with vue and some other websites that i have noticed like aws. – Vaibhav Singh Feb 26 '20 at 03:46
  • I came here with the same problem. Keydown is not working with vuejs on MacOS (Catalina and Monterey) in Chrome.. So this is not a single incident – eXXecutor Dec 05 '22 at 19:27

0 Answers0