# Disable pinch zoom on mobile

**URL:** <https://discourse.processing.org/t/disable-pinch-zoom-on-mobile/36100>\
**Category:** Coding Questions\
**Created:** [April 3, 2022, 10:47pm UTC](https://discourse.processing.org/t/disable-pinch-zoom-on-mobile/36100 "2022-04-03T22:47:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristan1](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@tristan1](https://discourse.processing.org/u/tristan1)\
**Post date:** [April 3, 2022, 10:47pm UTC](https://discourse.processing.org/t/disable-pinch-zoom-on-mobile/36100/1 "2022-04-03T22:47:21Z")

</div>

Hey everyone,

I am creating a litte pingpong game with multiple touch so that two player can play with each other on mobile device.

> **[p5.js Web Editor](https://editor.p5js.org/donnyhai/full/5WOqdYYj-)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

While playing the two touches trigger zooming in and out the screen, which strongly hinders the gameplay.

How can I prevent pinch zooming on a mobile device?

Thanks much for help, kind regards  
Tristan

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [April 4, 2022, 3:02am UTC](https://discourse.processing.org/t/disable-pinch-zoom-on-mobile/36100/2 "2022-04-04T03:02:02Z")

</div>

Some combination of the following should work, at least on iOS:

```auto
	// Prevent top level gesture scrolling/zooming
	// This if iOS Safari specific
	document.addEventListener('gesturestart', function(e) {
		e.preventDefault();
		return false;
	});

```

```auto
function touchStarted() {
	// This prevents scrolling gestures within the browser window
	return false;
}

```

---

<div class="post-metadata">

**Author:** ![tristan1](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@tristan1](https://discourse.processing.org/u/tristan1)\
**Post date:** [April 4, 2022, 11:13am UTC](https://discourse.processing.org/t/disable-pinch-zoom-on-mobile/36100/3 "2022-04-04T11:13:49Z")

</div>

On my Android device

```auto
function touchStarted() {
	// This prevents scrolling gestures within the browser window
	return false;
}

```

already worked! I will see how it can work on IOS, actually Im still struggling to get any touching interaction on IOS devices, maybe you know something on that too.

Thanks much!
