The problem with “repeated input” (the reason you created this thread) was likely caused by this.
There was a person with a similar problem a while ago, except that that person wanted the “repeated events” and complained when it stopped working.
Also note that you probably want to check the events using a while loop rather than an if statement otherwise you might run into other problems.