Solution 1 :

In the end, what i needed to do was to, instead of adding the event to the body, add the event to the text-box itself, that way, only when you click on the box it will keylog what you type, the final Js i had was this:

document.getElementById("Texto").addEventListener('keyup', function(event) {

    document.getElementById("Resultado").innerHTML+=(event.key);
    document.getElementById("Resultado2").innerHTML+=(event.keyCode+", ");

})
<body>
    <div id="Wrapper">
        <br>
        <h1>Key and Unicode Translator</h1>
        <input type="text" placeholder="Texto" id="Texto">

<br><br>

        <div id="Resultado"></div>
        <br>
        <div id="Resultado2"></div>
        <br>
    </div>

   
</body>

Problem :

Ive tried this, but it doesnt work, i’ve also tried to search for more info but i havent found anything.

document.getElementById("Text").addEventListener("select", myFunction);
function myFunction(){
document.body.addEventListener('keyup', function(event) {
    document.getElementById("Solution").innerHTML+=(event.key);
});
}

I want to know if there is a way to achieve something like this:

Pseudo-Code:

if(inputText==selected){
keyloggerFunction code... }

the keylogger works more or less, but i dont know if the if statement would be posible in any way.

By