Example 1 — Listen for touchend
Log a message whenever a finger lifts from the pad.
const pad = document.getElementById("pad");
const out = document.getElementById("out");
pad.addEventListener("touchend", (event) => {
out.textContent =
"touchend · lifted=" + event.changedTouches.length;
}); How It Works
- Get the pad. The element that receives the touch gesture.
- Register the listener.
addEventListener("touchend", …)runs when a contact leaves the surface. - Count lifted points.
changedTouches.lengthis how many fingers just lifted in this event. - Show the result. Update the status text so students can see the lift.

