Last active
February 12, 2017 14:32
-
-
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
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
// 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