DEV Community

Stephen Charles Weiss
Stephen Charles Weiss

Posted on • Originally published at stephencharlesweiss.com on

5 1

Replacing MouseEvents with PointerEvents

How can the necessity of handling different types of inputs (e.g., mouse, touch, and pen) by duplicating event handler logic? The Pointer Event makes a compelling case that it’s a solid solution.

pointerFigure1A pointer is a hardware agnostic representation of input devices that can target a specific coordinate (or set of coordinates) on a screen. 1

Pointer Events provide all the usual properties present in Mouse Events (client coordinates, target element, button states, etc.) in addition to new properties for other forms of input: pressure, contact geometry, tilt, etc. 2

While Pointer Events are not yet supported by all browsers, there is wide adoption among major modern browsers (Safari being the major exception, though support is coming in v13).3

can i use pointer events

This is a boon as pointer events will make the act of dealing with different input events much simpler.

Resources:

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs