Create events on mouseup

Separated event creation into its own function and only create events on the mouse up event.