--- title: TouchEvent slug: Web/API/TouchEvent translation_of: Web/API/TouchEvent ---
{{ APIRef("Touch Events") }}
La interfaz TouchEvent
representa un evento enviado cuando cambia el estado de los contactos con una superficie sensible al tacto. Esta superficie puede ser una pantalla táctil o un trackpad, por ejemplo. El evento puede describir uno o mas puntos de contacto con la pantalla e incluye soporte para detectar el movimiento, adición y remoción de puntos de contacto, etc.
Los toques pueden ser representados por el objeto {{ domxref("Touch") }}, cada toque es descrito por una posición, tamaño y forma, cantidad de presión, y el elemento que se presiona. Los toques son almacenados en el objeto {{ domxref("TouchList") }}
Constructor
Event
.Esta interfaz hereda propiedades de sus padres {{domxref("UIEvent")}} y {{domxref("Event")}}.
Hay varios tipos de eventos que pueden ser disparados (activados) para indicar que han ocurrido cambios relacionados con el contacto. Puede determinar cuál de estos ha ocurrido mirando la propiedad {{domxref ("event.type", "TouchEvent.type")}} del evento.
Sent when the user places a touch point on the touch surface. The event's target will be the {{ domxref("element") }} in which the touch occurred.
Sent when the user removes a touch point from the surface (that is, when they lift a finger or stylus from the surface). This is also sent if the touch point moves off the edge of the surface; for example, if the user's finger slides off the edge of the screen.
The event's target is the same {{ domxref("element") }} that received the touchstart
event corresponding to the touch point, even if the touch point has moved outside that element.
The touch point (or points) that were removed from the surface can be found in the {{ domxref("TouchList") }} specified by the changedTouches
attribute.
Sent when the user moves a touch point along the surface. The event's target is the same {{ domxref("element") }} that received the touchstart
event corresponding to the touch point, even if the touch point has moved outside that element.
This event is also sent if the values of the radius, rotation angle, or force attributes of a touch point change.
touchmove
events is sent is browser-specific, and may also vary depending on the capability of the user's hardware. You must not rely on a specific granularity of these events.Sent when a touch point has been disrupted in some way. There are several possible reasons why this might happen (and the exact reasons will vary from device to device, as well as browser to browser):
{{SeeCompatTable}}
See the example on the main Touch events article.
Specification | Status | Comment |
---|---|---|
{{SpecName('Touch Events 2','#touchevent-interface', 'TouchEvent')}} | {{Spec2('Touch Events 2')}} | Added ontouchstart , ontouchend , ontouchmove , ontouchend global attribute handlers |
{{SpecName('Touch Events', '#touchevent-interface', 'TouchEvent')}} | {{Spec2('Touch Events')}} | Definición inicial. |
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Soporte básico | {{CompatChrome("22.0")}} | {{CompatGeckoDesktop("18.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Soporte básico | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("6.0")}} | {{CompatVersionUnknown}} | 11 | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
TouchEvent() | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |