MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 47422 of Touch events (Mozilla experimental)

  • Revision slug: DOM/Touch_events_(Mozilla_experimental)
  • Revision title: Touch events (Mozilla experimental)
  • Revision id: 47422
  • Created:
  • Creator: MattBrubeck
  • Is current revision? No
  • Comment clarify state of the experimental vs. W3C draft APIs; 43 words added, 1 words removed

Revision Content

{{ gecko_minversion_header("2.0") }}

{{ deprecated_header("6.0") }}

Experimental support for touch events is added in {{ Gecko("2.0") }}. These allow you to track the movement of the user's finger on a touch screen, monitoring the raw touch events generated by the system. Although touch events are based on — and work similarly to — mouse events, each event includes an identifier that allows you to track multiple fingers moving on the screen at the same time.

Note: Firefox 6 for Android {{ geckoRelease("6.0") }} added support for the proposed W3C standard for touch events. You should use those instead of this API to develop content for Firefox on mobile devices.  Mozilla's experimental API is still available in Firefox for Windows, but it will likely go away in the future after the W3C finalizes a standard.

Event fields

Touch events are based upon mouse events, and thereby share all mouse event fields. They include one additional field.

streamId
A unique integer identifying the finger generating the event. When the MozTouchDown event is built, a unique value is assigned to that finger. Corresponding MozTouchMove and MozTouchUp events for that finger will have the same streamId value. This lets you track each finger's movements on the touch screen independently. The stream ID is unique until the MozTouchUp event occurs; after that, the value may be recycled for another series of events.

Types of touch events

MozTouchDown

Sent when the user begins a screen touch action.

MozTouchMove

Sent when the user moves his finger on the touch screen.

MozTouchUp

Sent when the user lifts his finger off the screen.

See also

Revision Source

<p>{{ gecko_minversion_header("2.0") }}</p>
<p>{{ deprecated_header("6.0") }}</p>
<p>Experimental support for touch events is added in {{ Gecko("2.0") }}. These allow you to track the movement of the user's finger on a touch screen, monitoring the raw touch events generated by the system. Although touch events are based on — and work similarly to — mouse events, each event includes an identifier that allows you to track multiple fingers moving on the screen at the same time.</p>
<div class="note"><strong>Note:</strong> Firefox 6 for Android {{ geckoRelease("6.0") }} added support for <a href="/en/DOM/Touch_events" title="en/DOM/Touch events">the proposed W3C standard for touch events</a>. You should use those instead of this API to develop content for Firefox on mobile devices.  Mozilla's experimental API is still available in Firefox for Windows, but it will likely go away in the future after the W3C finalizes a standard.</div>
<h2 id="Event_fields">Event fields</h2>
<p>Touch events are based upon mouse events, and thereby share all mouse event fields. They include one additional field.</p>
<dl> <dt>streamId</dt> <dd>A unique integer identifying the finger generating the event. When the <code>MozTouchDown</code> event is built, a unique value is assigned to that finger. Corresponding <code>MozTouchMove</code> and <code>MozTouchUp</code> events for that finger will have the same streamId value. This lets you track each finger's movements on the touch screen independently. The stream ID is unique until the <code>MozTouchUp</code> event occurs; after that, the value may be recycled for another series of events.</dd>
</dl>
<h2 id="Types_of_touch_events">Types of touch events</h2>
<h3 id="MozTouchDown">MozTouchDown</h3>
<p>Sent when the user begins a screen touch action.</p>
<h3 id="MozTouchMove">MozTouchMove</h3>
<p>Sent when the user moves his finger on the touch screen.</p>
<h3 id="MozTouchUp">MozTouchUp</h3>
<p>Sent when the user lifts his finger off the screen.</p>
<h2 id="See_also">See also</h2>
<ul> <li><a href="/en/DOM/Touch_events" title="en/DOM/Touch events">Touch events</a></li> <li><a class="internal" href="/en/DOM/event" title="En/DOM/Event"><code>event</code></a></li> <li><a class="internal" href="/En/Listening_to_events_in_Firefox_extensions" title="En/Listening to events">Listening to events</a></li>
</ul>
Revert to this revision