JS: Stylus touchstart event not triggerd if a finger is already touching the screen

Viewed 300

I want to do multi-touch events with an Apple pencil and a finger at the same time on a Web application. What I would like is:

  1. I touch and hold the screen with my finger, which trigger a touchstart and touchmove event;
  2. I touch the screen with my pencil while having my finger on the screen, which trigger a new touchstart event.

But the second touchstart event is never triggered. I cannot detect if a stylus is touching the screen if a finger is already touching the screen. I am using the Touch event framework for javascript. Here is the simple code I am using to detect the touch events:

canvas.addEventListener('touchstart', function(evt){
  evt.preventDefault();
  var s = "";
  for (i = 0; i < evt.targetTouches.length; i++){
    s += " Type: "+evt.targetTouches[i].touchType;
  }
  document.getElementById('result').innerHTML = s;
});

canvas.addEventListener('touchmove', function(evt){
  evt.preventDefault();
  var s = "";
  for (i = 0; i < evt.targetTouches.length; i++){
    s += " Type: "+evt.targetTouches[i].touchType;
  }
});

canvas.addEventListener('touchend', function(evt){
  evt.preventDefault();
});

I also try with evt.touches instead of evt.targetTouches but still does not work.

0 Answers
Related