TouchEvent

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

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 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 TouchList

Constructor

TouchEvent()

Crea un objeto TouchEvent.

Propiedades

Esta interfaz hereda propiedades de sus padres UIEvent y Event.

TouchEvent.altKey Read only

Un valor Booleano indicando si la tecla alt estaba pulsada cuando el evento touch fue lanzado.

TouchEvent.changedTouches Read only

Una lista TouchList objetos Touch representan puntos de contacto individuales cuyos estados cambiaron entre el evento touch previo y este.

TouchEvent.ctrlKey Read only

Un valor booleano que indica si la tecla de control estaba pulsada o no cuando el evento touch se disparó.

TouchEvent.metaKey Read only

Un valor Boleano que indica si la tecla meta estaba apagada o no cuando el evento touch se disparó.

TouchEvent.shiftKey Read only

Un valor Boleano que indica si la techa shift estaba apagado(presionada) cuando el evento touch se disparó.

TouchEvent.targetTouchesRead only

A TouchList of all the Touch objects that are both currently in contact with the touch surface and were also started on the same element that is the target of the event.

TouchEvent.touches Read only

A TouchList of all the Touch objects representing all current points of contact with the surface, regardless of target or changed status.

Tipos de evento táctiles

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 TouchEvent.type del evento.

Nota: Es importante observar que en muchos casos, Los eventos táctiles y de mouse se envían (para permitir que el código no táctil específico aún interactúe con el usuario). Si usa eventos táctiles, debe llamar a event.preventDefault () para evitar que también se envíe el evento del mouse.

touchstart

Sent when the user places a touch point on the touch surface. The event's target will be the element in which the touch occurred.

touchend

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 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 TouchList specified by the changedTouches attribute.

touchmove

Sent when the user moves a touch point along the surface. The event's target is the same 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.

Nota: The rate at which 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.

touchcancel

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):

  • An event of some kind occurred that canceled the touch; this might happen if a modal alert pops up during the interaction.
  • The touch point has left the document window and moved into the browser's UI area, a plug-in, or other external content.
  • The user has placed more touch points on the screen than can be supported, in which case the earliest Touch in the TouchList gets canceled.

GlobalEventHandlers

Experimental: Esta es una tecnología experimental
Comprueba la Tabla de compabilidad de navegadores cuidadosamente antes de usarla en producción.

GlobalEventHandlers.ontouchstart Experimental

A global event handler for the touchstart event.

GlobalEventHandlers.ontouchend Experimental

A global event handler for the touchend event.

GlobalEventHandlers.ontouchmove Experimental

A global event handler for the touchmove event.

GlobalEventHandlers.ontouchcancel Experimental

A global event handler for the touchcancel event.

Ejemplo

Especificaciones

Specification
Touch Events
# touchevent-interface

Compatibilidad con navegadores

BCD tables only load in the browser

See also