Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Why this is not getting captured in if block. Am I using && operator incorrectly? OutPut still shows CapsLock and Alt entered
const log = document.getElementById("log");

document.addEventListener("keydown", logKey);

function logKey(e) {
  if (e.key === "Shift" && "Control" && "CapsLock" && "Alt") {
    log.textContent += "";
  } else {
    log.textContent += ` ${e.key}`;
  }

  console.log(e);
}
#para {
  background: #f4f4f4;
  color: #333;
  border: 1px solid blue;
  height: 200px;
  width: auto;
}

#log {
  background: #333;
  color: #fff;
}
</pre>
<pre>

<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="./assets/styles/log.css" />
    <title>Getters and Setters</title>
    <script src="./assets/scripts/getter.js" defer></script>
  </head>
  <body>
    <div id="para">
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Expedita
        tempora distinctio quaerat vel iusto suscipit itaque dolor ipsa ducimus
        commodi eos maxime nemo temporibus, molestiae maiores. Similique
        reiciendis temporibus aut, optio tempora modi adipisci voluptatibus
        aspernatur explicabo, omnis atque nesciunt.
      </p>
    </div>
    <div id="log"></div>
  </body>
</html>

</pre>
const log = document.getElementById("log"); document.addEventListener("keydown", logKey); function logKey(e) { if (e.key === "Shift" && "Control" && "CapsLock" && "Alt") { log.textContent += ""; } else { log.textContent += ` ${e.key}`; } console.log(e); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!