[22] [DFN[[[Touch Events]]]] は、[[タッチ]]デバイスの操作による[[イベント]]についての
[[DOM]] 仕様です。

* 仕様書

[REFS[
- [23] [CITE@en[Touch Events]] ([TIME[2013-10-12 10:35:42 +09:00]] 版) <https://dvcs.w3.org/hg/webevents/raw-file/v1/touchevents.html>
- [48] [CITE@en[Touch Events]] ([TIME[2013-10-12 10:35:42 +09:00]] 版) <https://dvcs.w3.org/hg/webevents/raw-file/default/touchevents.html>
]REFS]

* インターフェイス

[FIG[
- [5] [CODE(DOMi)@en[[[Touch]]]] [SRC[>>23, >>48]]
- [7] [CODE(DOMi)@en[[[TouchList]]]] [SRC[>>23, >>48]]
- [6] [CODE(DOMi)@en[[[TouchEvent]]]] [SRC[>>23, >>48]]
- [42] [CODE(DOMi)@en[[[Document]]]] (旧 [CODE(DOMi)@en[[[DocumentTouch]]]]) [SRC[>>23, >>48]]
]FIG]

* イベント

[FIG[
- [8] [CODE(DOMe)@en[[[touchstart]]]] [SRC[>>23, >>48]]
- [9] [CODE(DOMe)@en[[[touchend]]]] [SRC[>>23, >>48]]
- [10] [CODE(DOMe)@en[[[touchmove]]]] [SRC[>>23, >>48]]
- [11] [CODE(DOMe)@en[[[touchcancel]]]] [SRC[>>23, >>48]]
- [43] [CODE(DOMe)@en[[[touchenter]]]] [SRC[>>48]]
- [44] [CODE(DOMe)@en[[[touchleave]]]] [SRC[>>48]]
]FIG]

* イベントハンドラー属性

[FIG[
- [49] [CODE(DOMa)@en[[[ontouchstart]]]]
- [50] [CODE(DOMa)@en[[[ontouchend]]]]
- [51] [CODE(DOMa)@en[[[ontouchmove]]]]
- [52] [CODE(DOMa)@en[[[ontouchcancel]]]]
- [53] [CODE(DOMa)@en[[[ontouchenter]]]]
- [54] [CODE(DOMa)@en[[[ontouchleave]]]]
]FIG]

* 処理モデル

[24] [[既定動作]]の詳細や[[マウスイベント]]との相互作用の詳細など、詳細な処理モデルは仕様上規定されていません。

[REFS[
- [32] [CITE@en[Touch Events]] ([TIME[2013-10-12 10:35:42 +09:00]] 版) <https://dvcs.w3.org/hg/webevents/raw-file/v1/touchevents.html#h3_touchevent-implementer-s-note>
- [25] [CITE@en[Touch Events]] ([TIME[2013-10-12 10:35:42 +09:00]] 版) <https://dvcs.w3.org/hg/webevents/raw-file/v1/touchevents.html#h2_mouse-events>
- [30] [CITE@en[Touch Events]] ([TIME[2013-10-12 10:35:42 +09:00]] 版) <https://dvcs.w3.org/hg/webevents/raw-file/v1/touchevents.html#h3_list-of-touchevent-types>
]REFS]

[FIG[
- [33] 同じ [CODE(DOMi)@en[[[TouchEvent]]]] に関連付けられた [CODE(DOMi)@en[[[Touch]]]] はすべて同じ[[文書]]のものとするべきです [SRC[>>32]]
-- [34] 最初の[[タッチ]]で[DFN[[RUBYB[[[''タッチ活性''文書]]]@en[''touch-active'' document]]]]を定め、
最後の[[タッチ点]]が離れるまで、それ以外の[[文書]]で始まった[[タッチ]]は無視するべきです [SRC[>>32]]
-- [35] この部分はなぜか[[規定]]ではなく[[参考]]とされています
- [26] [CODE(DOMe)@en[[[touchstart]]]] は[[マウスイベント]]の前に[[発送]]しなければなりません [SRC[>>25]]
- [27] [CODE(DOMe)@en[[[touchstart]]]] や [CODE(DOMe)@en[[[touchmove]]]] が [CODE(DOMm)@en[[[preventDefault]]]]
されたら、それに続く[[マウスイベント]]は[[発送]]しないべきです [SRC[>>25]]
- [28] [[タッチ]]を[[クリック]]として扱う場合、 [CODE(DOMe)@en[[[touchend]]]] の後に
[CODE(DOMe)@en[[[mousemove]]]], [CODE(DOMe)@en[[[mousedown]]]], [CODE(DOMe)@en[[[mouseup]]]],
[CODE(DOMe)@en[[[click]]]] の順に[[発送]]するべきです [SRC[>>25]]
-- [31] >>30 ([[参考]]) には[[タッチ点]]が移動していなければ [CODE(DOMe)@en[[[mousemove]]]] は不要であるようなことが書かれています
- [29] [[タッチイベント]]の間に[[文書]]に[[変異]]があったら、[[マウスイベント]]の[[対象]]は変わっていても構いません [SRC[>>25]]
]FIG]

* タッチ装置を持たないブラウザー

[55] [[Touch Events]] をいわゆる[[スマートフォン]]版の [[Webサイト]]への切り替えに使ったり、
[[Chrome]] や [[WebKit]] とその他のブラウザーの判定に使ったりする[[不思議]]サイトが非常に多いことから、
[[タッチ]]装置を有しない環境では [[Touch Events]] を無効にせざるを得なくなっています。
[[タッチ]]装置を有する[[デスクトップブラウザー]]や非 [[WebKit]] [[ブラウザー]]ではそのようなサイトは正しく動作しませんが、
有効な対策は見つかっていないようです。

[56] [[タッチ]]デバイスの無い[[デスクトップ]]版 [[Chrome]] は、 [CODE(DOMi)@en[[[Touch]]]],
[CODE(DOMi)@en[[[TouchList]]]], [CODE(DOMi)@en[[[TouchEvent]]]] の[[インターフェイスオブジェクト]]が存在しますが、
[CODE(DOMm)@en[[[createTouch]]]]、[CODE(DOMm)@en[[[createTouchList]]]]、[CODE(JS)@en[[[window]].[[ontouchstart]]]]
などは存在しないようです。同じく [[Firefox]] は、 [CODE(DOMi)@en[[[Touch]]]]
等も含めてすべて存在しないようです。 [TIME[2013-10-12T03:39:08.800Z]]

[REFS[
- [17] [CITE[won't fix: Touch Eventを実装したらいろんなサイトがぶっ壊れた]]
( ([TIME[2012-10-10 02:22:55 +09:00]] 版))
<http://wontfix.blogspot.jp/2012/10/touch-event.html>
-[45] [CITE@ja[モバゲーの各種ゲームのPCアクセスブロック実装を調べてみた | mof-brown engineer blog]]
( ([TIME[2013-10-12 03:05:55 +09:00]] 版))
<http://blog.mof-brown.jp/archives/81>
-[47] [CITE@en[798821 – Disable touch events on Windows for devices that do not support touch input]]
( ([TIME[2013-10-12 03:20:50 +09:00]] 版))
<https://bugzilla.mozilla.org/show_bug.cgi?id=798821>
]REFS]

;; [57] このような実装上極めて重要な情報はなぜか [[W3C]] [[勧告]]にもまったく言及がありません。

* タッチ操作

;; [85] [[マウス操作]]も参照。

[FIG(list middle)[
- [[スクロール]]
- [[再読み込み]]
- [[ズーム]]
]FIG]

* 歴史

** WebKit での実装

[58] [[Touch Events]] ははじめ [[Mobile Safari]] で実装されました。

** 第1版

[59] [[W3C]] で [[Web Events WG]] が組織され、 [[Touch Events]] 仕様書となりました。ただし [[Apple]]
はこの [[WG]] に参加していません。

[60] [[Touch Events]] 仕様は後に第1版と第2版に分割されています ([[W3C]] ではよくあること)。

[REFS[
-[1] [CITE@en[Touch Events Specification]]
( ([TIME[2011-02-13 11:20:35 +09:00]] 版))
<http://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html>
-[2] [CITE@en[Touch Events Specification]]
( ([TIME[2011-05-03 06:39:56 +09:00]] 版))
<http://www.w3.org/TR/2011/WD-touch-events-20110505/>
-[3] [CITE[Touch Events version 1]]
( ([TIME[2011-09-13 04:42:32 +09:00]] 版))
<http://www.w3.org/TR/2011/WD-touch-events-20110913/>
-[4] [CITE@en[Touch Events version 1]] ([TIME[2011-10-08 12:18:01 +09:00]] 版) <http://dvcs.w3.org/hg/webevents/raw-file/v1/touchevents.html>
-[12] [CITE[Touch Events version 1]]
( ([TIME[2011-10-26 22:53:49 +09:00]] 版))
<http://www.w3.org/TR/2011/WD-touch-events-20111027/>
-[13] [CITE[Touch Events version 1]]
( ([TIME[2011-12-15 04:28:37 +09:00]] 版))
<http://www.w3.org/TR/2011/CR-touch-events-20111215/>
]REFS]

** PAG

[61] [[W3C]] の [[Patent Policy]] に則った手続きで [[Apple]] が関連[[特許]]の保有を通知したため、
[[PAG]] が設けられ、その影響が検討されました。 [[Touch Events]] 仕様書には影響しないという結論になり、
[[W3C]] [[勧告]]に進めることになりました。

[REFS[
-[14] [CITE[public-te-pag@w3.org Mail Archives]]
( ([TIME[2012-01-28 03:47:46 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-te-pag/>
-[15] [CITE@en-US[TEPAG - Touch Events Patent Advisory Group Charter]]
( ([TIME[2012-01-31 08:09:34 +09:00]] 版))
<http://www.w3.org/2012/01/touch-pag-charter>
-[16] [CITE@en[Touch Events Patent Advisory Group Report]]
( ([TIME[2012-07-03 05:58:11 +09:00]] 版))
<http://www.w3.org/2012/te-pag/pagreport.html>
]REFS]

** 第1版勧告

[REFS[
-[18] [CITE@en[Touch Events version 1]]
( ([TIME[2013-01-23 06:45:06 +09:00]] 版))
<http://www.w3.org/TR/2013/WD-touch-events-20130124/>
-[21] [CITE@en[Touch Events]]
( ([TIME[2013-10-10 21:37:14 +09:00]] 版))
<http://www.w3.org/TR/2013/REC-touch-events-20131010/>
-[36] [CITE[Index of /webevents/tests/touch-events-v1/approved]]
( ([TIME[2013-10-12 02:32:50 +09:00]] 版))
<http://w3c-test.org/webevents/tests/touch-events-v1/approved/>
-[37] [CITE[TEv1ImplReport - Web Events Wiki]]
( ([TIME[2013-06-13 12:01:58 +09:00]] 版))
<http://www.w3.org/2010/webevents/wiki/TEv1ImplReport>
-[19] [CITE@en[Touch Events version 1]]
( ([TIME[2013-05-09 05:16:13 +09:00]] 版))
<http://www.w3.org/TR/2013/PR-touch-events-20130509/>
-[20] [CITE[Touch Events Accessibility Mapping - Protocols and Formats Working Group Wiki]]
( ([TIME[2013-03-07 02:44:07 +09:00]] 版))
<http://www.w3.org/WAI/PF/wiki/Touch_Events_Accessibility_Mapping>
]REFS]

[62] なお[[勧告]]化にあたり、 [[ED]] 状態で活発に開発が進んでいるものの [[W3C Process]] 上は [[CR]]
な [[WebIDL]] を参照していることが [[W3C Process]] 上問題になり、 [[W3C Director]] である [[TimBL]]
から物言いがつき、 [[WebIDL]] の一部規定を曖昧にコピペすることで決着しています ([[W3C]]ではよくあること)。
詳しくは [[W3C Process]] の項を参照。

** Gecko での実装

[63] [[Gecko]] は独自に [CODE(DOM)@en[[[MozTouch]]]] 系イベントを実装していましたが、 [[Touch Events]]
に切り替えています。その過程で >>55 のような問題も見つかりました。

[REFS[
- [46] [CITE@en[726615 – Support W3C touch event instead of MozTouch event]]
( ([TIME[2013-10-12 03:16:29 +09:00]] 版))
<https://bugzilla.mozilla.org/show_bug.cgi?id=726615>
]REFS]

** 第2版

[64] 元の [[WebKit]] の実装になかった [CODE(DOMa)@en[[[radiusX]]]] や
[CODE(DOMe)@en[[[touchenter]]]] などの追加分は第2版として分離されていましたが、
[[Pointer Events]] と競合するおそれがあることからこれを取りやめ、 [[Web Events WG]] も終了することになりました。

[65] ただし [[Firefox]] はこれら追加分も既に実装しています。 [TIME[2013-10-12T03:50:44.400Z]]

[REFS[
-[38] [CITE@en[Touch Events version 2]]
( ([TIME[2013-10-12 02:35:31 +09:00]] 版))
<https://dvcs.w3.org/hg/webevents/raw-file/default/touchevents.html>
-[39] [CITE[PubStatus - Web Events Wiki]]
( ([TIME[2013-10-11 11:12:43 +09:00]] 版))
<http://www.w3.org/2010/webevents/wiki/PubStatus>
-[40] [CITE@en[What must be done to publish a Working Group Note of Touch Events  v2?]]
( ([[Arthur Barstow]] 著, [TIME[2013-10-11 20:46:07 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-webevents/2013OctDec/0008.html>
-[41] [CITE@en[CfC: to publish Touch Events v2 as a WG Note; deadline Oct 21]]
( ([[Arthur Barstow]] 著, [TIME[2012-10-14 22:45:37 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-webevents/2012OctDec/0009.html>
]REFS]

;; [66] 第2版は第1版も包含していますが、第1版の部分に分離後加えられた変更は第2版にすべては反映されていないようです。
([[W3C]]ではよくあること。)



[67] [CITE[Touch Events incremental improvements - Google ドキュメント]]
( ([TIME[2014-11-07 11:45:31 +09:00]] 版))
<https://docs.google.com/a/chromium.org/document/d/1x-yE4CmTZlZQXea4_FPjgly5TOvF28UBNs9gZ5aGUhg/edit?pli=1>

[68] [CITE[IRC logs: freenode / #whatwg / 20141215]]
( ([TIME[2014-12-16 11:15:13 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20141215#l-356>

[69] [CITE[public-touchevents@w3.org Mail Archives]]
( ([TIME[2014-12-20 06:59:23 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-touchevents/>

[70] [CITE@en-US[webevents: Summary]]
( ([TIME[2015-01-02 22:21:23 +09:00]] 版))
<https://dvcs.w3.org/hg/webevents/summary>

[71] [CITE@en[Touch Events CG Call -- 16 Dec 2014]]
( ([TIME[2014-12-17 03:11:43 +09:00]] 版))
<http://www.w3.org/2014/12/16-touchevents-minutes.html>

[72] [CITE@en[Touch Events]]
( ([TIME[2015-01-02 22:24:11 +09:00]] 版))
<https://dvcs.w3.org/hg/webevents/raw-file/v1-errata/touchevents.html>

[73] [CITE@en[Touch Events Accessibility Mapping - Protocols and Formats Working Group Wiki]]
( ([TIME[2014-08-27 19:33:53 +09:00]] 版))
<http://www.w3.org/WAI/PF/wiki/Touch_Events_Accessibility_Mapping>

[74] [CITE@en[Touch Events Extensions]]
( ([TIME[2013-10-29 05:03:47 +09:00]] 版))
<http://www.w3.org/TR/touch-events-extensions/>

[75] [CITE@en[Touch Events Extensions]]
( ([TIME[2013-10-29 05:03:47 +09:00]] 版))
<http://www.w3.org/TR/2013/NOTE-touch-events-extensions-20131031/>

[76] [CITE@en[Touch Events Errata]]
( ([TIME[2014-12-17 02:06:22 +09:00]] 版))
<http://www.w3.org/TR/2013/REC-touch-events-20131010/REC-touch-events-20131010-errata.html>

[77] [CITE@en[w3c/touch-events]]
( ([TIME[2015-01-02 22:26:48 +09:00]] 版))
<https://github.com/w3c/touch-events>

[78] [CITE@en[Touch Events Community Group]]
( ([TIME[2014-12-17 04:10:11 +09:00]] 版))
<https://www.w3.org/community/touchevents/wiki/Main_Page>

[79] [CITE[Touch event behavior details across browsers - Google ドキュメント]]
( ([TIME[2015-01-02 22:28:14 +09:00]] 版))
<https://docs.google.com/a/chromium.org/document/d/12k_LL_Ot9GjF8zGWP9eI_3IMbSizD72susba0frg44Y/edit>

[80] [CITE@en-US[Touch Events Community Group]]
([TIME[2015-02-26 11:22:28 +09:00]] 版)
<https://www.w3.org/community/touchevents/>

[81] [CITE@en[w3c/touch-events]]
([TIME[2015-02-26 11:24:43 +09:00]] 版)
<https://github.com/w3c/touch-events>

[82] [CITE@en[Touch Events Extensions]]
([TIME[2015-02-26 11:24:54 +09:00]] 版)
<http://rawgit.com/w3c/touch-events/master/touchevents.html>

[83] [CITE@en[Touch Events v1 (with Errata Included)]]
([TIME[2015-02-26 11:25:25 +09:00]] 版)
<http://rawgit.com/w3c/touch-events/v1-errata/touchevents.html>

[84] [CITE[Identifying MouseEvents derived from TouchEvents - Google ドキュメント]]
([TIME[2015-03-12 11:37:41 +09:00]] 版)
<https://docs.google.com/a/chromium.org/document/d/1-ZUtS3knhJP4RbWC74fUZbNp6cbytG6Wen7hewdCtdo/edit?pli=1#heading=h.rbcct8al2kop>

[86] [CITE@en[Changed license, changed WG info to CG, used CG stylesheet · w3c/touch-events@418619f]]
([TIME[2016-03-19 14:10:45 +09:00]] 版)
<https://github.com/w3c/touch-events/commit/418619fb7b853a322254d3dd474c01715c2d248a>

[87] [CITE@en[Make document.createEvent("touchevent") sometimes throw · whatwg/dom@cb7c16b]]
([TIME[2016-04-20 15:29:37 +09:00]] 版)
<https://github.com/whatwg/dom/commit/cb7c16b764d64e43da1f9d62da7d4066341ff0e5>

[88] [CITE@en[Add @patrickhlauke as editor]]
( ([[@patrickhlauke]]著, [TIME[2016-06-08 22:50:59 +09:00]]))
<https://github.com/w3c/touch-events/commit/0e9c9fa941e2ed4977e17640f9c54754c9bdb247>

[89] [CITE[Touch event behavior details across browsers - Google ドキュメント]]
([TIME[2016-07-12 01:15:07 +09:00]])
<https://docs.google.com/document/d/12k_LL_Ot9GjF8zGWP9eI_3IMbSizD72susba0frg44Y/edit?pref=2&pli=1>

[90] [CITE[Touch scrolling intervention in Chromium - Google ドキュメント]]
([TIME[2016-07-12 01:16:00 +09:00]])
<https://docs.google.com/document/d/1mlUcJZHLyz1fip7CNEiU0w7JgcxBZUilvOwg0i9ZvQc/edit?pref=2&pli=1#heading=h.4lsqlgilqy1g>

[91] [CITE@en[Forced passive touch listeners · Issue #18 · WICG/interventions]]
([TIME[2016-07-12 01:16:08 +09:00]])
<https://github.com/WICG/interventions/issues/18>

[92] [CITE@en[Reference TouchEvents spec for compat mouse events (#119)]]
([[NavidZ]]著, [TIME[2016-07-29 13:29:07 +09:00]])
<https://github.com/w3c/pointerevents/commit/4c0a51b52526c1b48afa2a6bce4858aa238a1f11>

[93] [CITE@en[Add Safari iOS 10.3 extensions for stylus]]
([[RByers]]著, [TIME[2017-04-21 15:54:02 +09:00]])
<https://github.com/w3c/touch-events/commit/c1ded16b10517e686b0fed06eb5e0b7839003c72>

[94] [CITE@en[Add '''['''Exposed=Window''']''' to Constructor (#88)]]
([[patrickhlauke]]著, [TIME[2017-09-22 17:46:08 +09:00]])
<https://github.com/w3c/touch-events/commit/b12e03f49b98725105b0b0f2aeb912bea2562933>

[95] [CITE@en[Ask for tests for normative changes in README (#90)]]
([[foolip]]著, [TIME[2017-10-23 20:25:13 +09:00]])
<https://github.com/w3c/touch-events/commit/2d98e7de2fae6dba494b714da67b879fa328adac>

[96] [CITE@en[Ask for tests for normative changes in README by foolip · Pull Request #90 · w3c/touch-events]]
([TIME[2017-10-24 17:48:56 +09:00]])
<https://github.com/w3c/touch-events/pull/90>