dude dude - 4 years ago 135
Javascript Question

Touch API (e.g. touchstart) not working in MS Edge

my application is using the Touch API to detect touch events in JavaScript. Example:

$(".element").on("touchstart", function(event){

This works on any touch device with any browser like Android or iOS, however it doesn't work in MS Edge on a Windows 10 Tablet with or without conntected keyboard. The API seems to be supported: Compatibility list. However, I've tested:
'ontouchstart' in window
and this returns false on this device. Furthermore
seems to get fired.

What is going on here? What can I do to fire touch events on a Windows 10 tablet?
I would like to keep the event only for touch devices. Switching to the Pointer Events API would include also Desktop devices and that is not what I want.

Answer Source

for touch API, you have to activate a flag on Edge : in the address bar, enter about:flags and press enter. In the section Touch, you can enable touch events with the corresponding dropdown

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download