I want to remove this listeners at the and of the game from window without reference. How to do that? It can be removed, detached, whatever just I want to be them off.
actionListeners = () => {
window.addEventListener("keydown", (e) => {
if (e.key === "ArrowLeft") {
this.isArrowLeft = true;
} else if (e.key === "ArrowRight") {
this.isArrowRight = true;
}
});
window.addEventListener("keyup", (e) => {
if (e.key === " ") {
this.executeShot();
}
if (e.key === "Control") {
this.executeBarrier();
}
if (e.key === "ArrowLeft") {
this.isArrowLeft = false;
} else if (e.key === "ArrowRight") {
this.isArrowRight = false;
}
});
};