TouchEvent

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 (en-US), 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 (en-US)

Constructor

TouchEvent() (en-US)

Crea un objeto TouchEvent.

Propiedades

Esta interfaz hereda propiedades de sus padres UIEvent y Event.

TouchEvent.altKey (en-US) Read only

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

TouchEvent.changedTouches (en-US) Read only

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

TouchEvent.ctrlKey (en-US) Read only

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

TouchEvent.metaKey (en-US) Read only

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

TouchEvent.shiftKey (en-US) Read only

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

TouchEvent.targetTouches (en-US)Read only

A TouchList (en-US) of all the Touch (en-US) 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 (en-US) Read only

A TouchList (en-US) of all the Touch (en-US) 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 (en-US)

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 (en-US)

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 (en-US) specified by the changedTouches attribute.

touchmove (en-US)

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 (en-US)

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 (en-US) in the TouchList (en-US) gets canceled.

GlobalEventHandlers

Ejemplo

Especificaciones

Specification
Touch Events
# touchevent-interface

Compatibilidad con navegadores

BCD tables only load in the browser

See also