Attaches listeners for the events that you give as parameters in the function.