bhylu.com

Advertisements

API Web Pointer

Pointer events cover mouse, pen, and touch input through one event family. A button still needs normal click semantics for keyboard activation.

Where to run this

This example changes a document. Open it in the HTML playground, then select Run code. It runs inside a separate preview.

A practical example

HTML + JavaScript

<button id="pad" type="button">Try a pointer</button>
<p id="type"></p>
<script>
  document.getElementById("pad").addEventListener("pointerdown", event => {
    document.getElementById("type").textContent = "Pointer: " + event.pointerType;
  });
</script>

What happens

The message reports the pointer type used.