I'm working with a function in Angular 4 that is triggered when the arrow down key is pressed. Each time the arrow down key is hit, the counter increments by 1. In this function, I need to run another function if the counter reaches a certain speed.
activeIndex = 0;
if (event.code === "ArrowDown") {
this.activeIndex++ // Counter increments each time arrow down is clicked
if (this.activeIndex === "the desired speed"){
alert("The other function will be fired because the speed was reached.")
}
Is there a way to calculate the speed at which the counter increments?