0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

TouchEventで指の数によって処理を変える

Posted at

はじめに

タイトル通りですが、TouchEventで指の数によって処理を変える方法を紹介します。

実装方法

main.js
let recentTouchEvent
document.body.ontouchstart = (e) => {
    recentTouchEvent = e
}
document.body.ontouchend = (e) => {
    if (e.touches.length === 0) {
        if (recentTouchEvent.touches.length === 1) {
            alert('1本指でタッチ')
        }
        if (recentTouchEvent.touches.length === 2) {
            alert('2本指でタッチ')
        }
    }
}

おわりに

指摘、提案、その他のコメントは大歓迎です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?