In Mobile Safari, is there any way to distinguish whether a touch event is generated by finger or Apple Pencil?
Drawing mode is entered by tapping on the drawing tools icon, which looks like a little pencil tip with a circle around it. Once you tap that you will access the drawing tools in Notes app (and Markup) and you're able to draw with your finger.
Apple doesn't provide a specific pressure sensitivity level for the Apple Pencil. Tilt Sensitivity - Apple Pencil is designed to work like a regular pencil, so if you hold it at an angle and press the side of the tip alongside the iPad for something like shading, it works.
By default, Apple Pencil 2 responds to the double-tap gesture by toggling between the current tool and the eraser, but people can set double-tap to toggle between the current and previous tool, show and hide the color picker, or do nothing at all.
The TouchList
object of a touch event contains detailed information about the touch’s individual points. Among the many properties touchType
is probably the most interesting for you as it contains either "stylus"
(Apple Pencil) or "direct"
(finger).
var body = document.querySelector('body');
body.addEventListener('touchstart', function(evt){
// should be either "stylus" or "direct"
console.log(evt.touches[0].touchType);
});
You should also have a look at the other properties of each individual Touch like force
or azimuthAngle
that can give you detailed information about the touch point’s current device(s).
Please note that the Touch interface is only part of a W3C working draft and not official standard yet – however works in iOS 10 + Safari + Apple Pencil.
You can check the touch force with:
e.touches[0].force;
But it works also for 3DTouch on iPhone 6s.
Only Apple Pencil events and touches events on iPhone 6s have .force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With