add event handler for input