17

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

$(".element").on("touchstart", function(event){
    alert("TRUE");
});

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 mousedown 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.

Web_Designer
  • 72,308
  • 93
  • 206
  • 262
dude
  • 5,678
  • 11
  • 54
  • 81
  • hi, did you manage to progress on the issue? – Eugene Tiurin Nov 01 '15 at 22:06
  • No, in fact I'm still waiting for a solution and did not find any workaround for it. If no one replies a solution I think the only option is to also listen for mouse-events. – dude Nov 02 '15 at 08:13

3 Answers3

17

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

t.ouvre
  • 2,856
  • 1
  • 11
  • 17
  • I'll check this out in new year. – dude Dec 22 '15 at 15:49
  • In fact this property was disabled. I don't know the reason why it was disabled, but after activating it, touch events are getting fired correctly. Maybe a Windows 10 upgrade issue... – dude Jan 04 '16 at 14:51
  • FYI - I needed to do this AND add the style tag: `-ms-touch-action: none;` mentioned your other answer – thab Feb 19 '16 at 11:49
  • 5
    Is this solution helpful for the WWW in general? Most users aren't going to have this flag enabled, or care / know about enabling it. – trismi Jun 13 '16 at 20:36
  • 2
    @trismi Features that aren't enabled by default don't exist. No user will configure their browser's hidden features. They just say it doesn't work. Then I just have to say, get a real browser. Edge is the new IE?! There was hope. – ygoe Dec 21 '17 at 20:45
5

Did you enable custom touch handling ? You can do it with the following css snippet (on the body tag or just a container for geastures) :

-ms-touch-action: none;

Next, touch API is a webkit feature (maybe there is an error in CanIuse ?). IE and Edge have a similar feature known as Pointer API. But you can use a polyfill library like this : https://github.com/CamHenlin/TouchPolyfill

t.ouvre
  • 2,856
  • 1
  • 11
  • 17
  • You will **disable** touch actions with this CSS. As I already mentioned touch events are supported, refer http://caniuse.com/#search=touch. And I don't want to support mouse events and this would be the fact with Pointer API. I have described this too. – dude Dec 12 '15 at 09:08
  • 1
    @julmot, it's wrong. ms-touch-action to none is required to enable custom gesture handling. Without that, your browser use a default behavior (for scrolling handling, panning, pinch & zoom). If you want build custom gesture (and use Pointer API), you have to set ms-touch-action to none. For the last version of Edge, "-ms-touch-action" must be replaced by "touch-action". Just trust me and try to use PointerMove event on the body of a page with touch-action to none and nothing. You will see wath I mean. – t.ouvre Dec 14 '15 at 09:50
  • @julmot, for touch API, you have to activate a flag on Edge : in the url input, enter about:flags. In the section Touch, you can enable touch events with the corresponding dropdown. – t.ouvre Dec 14 '15 at 18:00
  • Thanks for this hint! – dude Jan 04 '16 at 14:52
0

Try using the pointerdown event. Some (much) more information. As you can see, touchstart is triggered by Edge but not in all configurations, when a keyboard is attached/paired for example, no touchstart.

Shanoor
  • 13,344
  • 2
  • 29
  • 40
  • Yes but the ```touchstart``` event is even not getting fired if I have no keyboard connected. Also I would like to keep this event just for touch devices and not for desktop devices (what would be the case with Pointer API). – dude Oct 23 '15 at 12:16
  • Is it a bluetooth keyboard? Having one paired seems to be enough to not trigger the event, it's quite stupid. – Shanoor Oct 23 '15 at 12:25
  • I have an ASUS Tablet that comes with a docking station. The docking station includes a keyboard. So if I disconnect it from the dockingstation I expect it to the a "native" touch-tablet that should be detected as such. – dude Oct 23 '15 at 12:35
  • The pointer events are not working, too. So Edge simply has nothing to offer on touch devices. All the advertisement was wrong. – ygoe Dec 21 '17 at 20:46