optimize inputevent