Languages
[Edit]
EN

JavaScript - touch events example (on touch screen)

5 points
Created by:
Dexter
660

In this article, we would like to show how to use touch events on touch screen under JavaScript.

Touch events example in JavaScript.
Touch events example in JavaScript.

Quick solutions:

1. HTML event attribute:

2. Element event property

3. Element event listener

 

There are available following events:

Event nameEvent description
touchstart

Occurs when on touch screen some touch point appears.
e.g. user put some finger on the screen.

touchmove

Occurs when some touch point changes position.
e.g. user moves finger on the screen.

touchendOccurs when on touch screen some touch point is removed.
e.g. user takes some finger from the screen.
touchcancelOccurs when some touch point case is not supported.
e.g. too many touch points are used.

Warning: the events will be not working with mouse.

 

Practical examples

Edit

In this section, we have placed practical exmaples for the quick solutions.

1. HTML event attribute example

Edit

 

2. Element event property example

Edit

 

3. Element event listener example

Edit

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join