remove/prevent chrome mobile dev tools context menu on long tap
Asked Answered
K

1

6

I'm developing(debugging) a mobile app on chrome's mobile simulator, and I kinda irritated on chrome's context menu when you press and hold on the mobile. Is there a way to remove/prevent it from showing? Is there a feature on chrome to manually remove it?

I'd tried even using css user-select: none(prefix included), it is still showing it.

Kalikow answered 28/4, 2015 at 17:1 Comment(1)
Does this answer your question? How to disable the context menu on long press when using device mode in Chrome?Dang
B
3

Listen for the contextmenu event and call its preventDefault() method:

yourDomElement.addEventListener('contextmenu', (event) => {
  event.preventDefault();
});

Since the event bubbles, you can put this anywhere up the DOM tree from the long-tapped element, even document.body. Just remember to take it off when you're finished debugging, otherwise users won't be able to open the right-click menu at any time.

Bohannan answered 18/5, 2023 at 21:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.