Home > OS >  Keyboard Not detecting input
Keyboard Not detecting input

Time:10-11

Hello I am making a website, and am trying to make a keyboard shortcut, but it can't detect the key.

Here is my code:

document.addEventListener("keydown, (e) => {
  if(e.key === "l" && e.ctrlKey && e.shiftKey){
   console.log("Please Work I Beg Of You")
   }
})

Let me know if you need more information

CodePudding user response:

No more information needed. The computer will read the L key as being capital because you pressed shift, so just change it to "L" (I'm not sure if this'll work, but might also be able to do e.key.toLowerCase()). Let me know if this works

CodePudding user response:

you can check keyCode instead

document.addEventListener("keydown", (e) => {
  if (e.keyCode === 76 && e.ctrlKey && e.shiftKey) console.log("Please Work I Beg Of You");
});

  • Related