Skip to content

Instantly share code, notes, and snippets.

@Xatpy
Created February 19, 2015 16:59
Show Gist options
  • Select an option

  • Save Xatpy/814d5df9e1911fd83e64 to your computer and use it in GitHub Desktop.

Select an option

Save Xatpy/814d5df9e1911fd83e64 to your computer and use it in GitHub Desktop.
Test events
<!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