Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active February 12, 2017 14:32
Show Gist options
  • Save daliborgogic/5600fa7c505e0848919f7f4416a05d53 to your computer and use it in GitHub Desktop.
Save daliborgogic/5600fa7c505e0848919f7f4416a05d53 to your computer and use it in GitHub Desktop.
Input-specific event handling by using a single pointer event you can use the pointerType property
// https://w3c.github.io/pointerevents/
foo.addEventListener('pointerdown', e => {
switch (e.pointerType) {
case 'mouse':
// mouse detected
break
case 'pen':
// pen / stylus detected
break;
case 'touch':
// touch detected
break
default:
// pointerType unknown or cannot be detected
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment