Created
February 19, 2015 16:59
-
-
Save Xatpy/814d5df9e1911fd83e64 to your computer and use it in GitHub Desktop.
Test events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <title>Test events</title> | |
| <script type="text/javascript"> | |
| function TouchStartResponse(event) { | |
| document.getElementById("dvTouchStatus").innerHTML += "TouchStart<br />"; | |
| } | |
| function TouchEndResponse(event) { | |
| document.getElementById("dvTouchStatus").innerHTML += "TouchEnd<br />"; | |
| } | |
| function MouseDownResponse(event) { | |
| document.getElementById("dvMouseStatus").innerHTML += "Mouse Down<br />"; | |
| } | |
| function MouseUpResponse(event) { | |
| document.getElementById("dvMouseStatus").innerHTML += "Mouse Up<br />"; | |
| } | |
| function PointerDownResponse(event) { | |
| document.getElementById("dvPointerStatus").innerHTML += | |
| "PointerId:" + event.pointerId + | |
| " of pointerType:" + event.pointerType + " Down<br />"; | |
| } | |
| function PointerUpResponse(event) { | |
| document.getElementById("dvPointerStatus").innerHTML += | |
| "PointerId:" + event.pointerId + | |
| " of pointerType:" + event.pointerType + " Up<br />"; | |
| } | |
| function init() { | |
| console.log('window.navigator.msPointerEnabled: ' + window.navigator.msPointerEnabled); | |
| document.addEventListener("mousedown", MouseDownResponse); | |
| document.addEventListener("mouseup", MouseUpResponse); | |
| document.addEventListener("touchstart", TouchStartResponse); | |
| document.addEventListener("touchend", TouchEndResponse); | |
| document.addEventListener("pointerdown", PointerDownResponse); | |
| document.addEventListener("pointerup", PointerUpResponse); | |
| //Support for prefixed IE10 implementation | |
| document.addEventListener("MSPointerDown", PointerDownResponse); | |
| document.addEventListener("MSPointerUp", PointerUpResponse); | |
| } | |
| </script> | |
| </head> | |
| <body onload="init()"> | |
| <p>Click, touch, or tap</p> | |
| <table> | |
| <tr> | |
| <td style="vertical-align:top; width:30%;"><div id="dvMouseStatus"></div></td> | |
| <td style="vertical-align:top; width:40%;"><div id="dvPointerStatus"></div></td> | |
| <td style="vertical-align:top; width:40%;"><div id="dvTouchStatus"></div></td> | |
| </tr> | |
| </table> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment