Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Log all pointer events (mouse and touch gestures)
(function () {
var span, eventTypes = [
'click', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout',
'touchstart', 'touchend', 'touchmove', 'touchcancel', 'touchleave'
var header = document.querySelector('#header .header-wrap');
// Log a single gesture to the console and show it at the top of the page.
function logEvent (event) {
span = document.createElement('span'); = 'white';
span.appendChild(document.createTextNode(event.type + ' -> '));
header.insertBefore(span, header.firstChild);
// Attach event listeners for all gestures.
for (var i = 0; i < eventTypes.length; i++) {
document.addEventListener(eventTypes[i], logEvent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment