event handling for touch and desktop refactored