Last active
December 19, 2015 03:19
-
-
Save Matt-Jensen/5889842 to your computer and use it in GitHub Desktop.
This could be a horrible idea but this is a short function that detects the supported pointer type and returns a string to use with event listeners.
This file contains 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
// Determine the supported pointer event, whether click or touch ect. | |
function supportedClickEvent() { | |
var supportedEvent = 'click'; | |
if( 'ontouchstart' in window ) { | |
supportedEvent = 'touchstart'; | |
} | |
else if( window.navigator.msPointerEnabled ) { | |
supportedEvent = 'MSPointerDown'; | |
} | |
else if( 'pointerdown' in window ) { | |
supportedEvent = 'pointerdown'; | |
} | |
return supportedEvent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment