I have a piece of code where the user when he/she presses `NumpadEnter` key, a certain function triggers:

```
document.addEventListener("keyup", function(event) {
    if (event.code === "NumpadEnter") {   
         //some logic here    
    }
}

```

Now I want to trigger this `keyup` function when a certain condition is met:

```
if(flag == true){
    //trigger the keyup listener
}

```

How do I do that?