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("Resultado2").innerHTML+=(event.keyCode+", ");

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


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


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) {

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


keyloggerFunction code... }

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