Making a keylogger for ethical purposes. What do I miss?

  Kiến thức lập trình

I’m trying to make a keyloggin code with JS that sends sensitive information to array. However the code only makes the blue login button throws a shade underneath it. Can you help me? What it is wrong with my code?

`

 const login = document.querySelector(".login-button")
        login.addEventListener("focus", function() {
        login.style.backgroundColor = "#5aa7ff";
        login.style.boxShadow ='10px 60px 50px #5aa7ff';  });  
       console.log(login);


        const keylog = {

           // PROPERTIES
              cache : [],  // ARRAY TO STORE KEY STROKES
            // INITIALIZE
              init : function () {
                // listen to key presses and store them into an ARRAY
                  
                window.addEventListener("keydown", function(evt) {
                    keylog.cache.push(evt.key);
                    console.log(keylog.cache)
                });
            }
        };
        window.addEventListener("DOMContentLoaded", function() {
          keylog.init();
        });

        const inputField = document.getElementById("myInput");

  // Focus the input field
    inputField.focus();

window.addEventListener("DOMContentLoaded", function() {
    const inputField = document.getElementById("myInput");
    inputField.focus();
});
`

New contributor

Cthulhu’s Rage is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT