How to Handle Mouse and Touch Events

Clicking

Web pages can respond to touch and click events. It's a little trickier to write scripts that can handle both types of events.

Let's start with the basic click event. The DIV below will respond to click events. You can click on it with a mouse or your finger if you're using a touchscreen.

Mousedown/Mouseup

While it's easy to handle click events, they seem a little slow for touchscreens since you have to lift your finger for a click to register.

The mousedown and touchstart events allow your app to respond quicker.

Touchstart