Search code examples
javascriptselecttouch

holding a button touched on smartphone causes the button element to be selected


I have studied my earlier problem with onmousedown and ontouchstart, and I now realized that with smartphones (at least with android), holding the finger touch pressed without moving normally causes the element to be selected. Whereas, with a mouse, holding the click pressed works perfectly fine.

Now, my problem is that my goal is that the user has to do some effort in order to make a stack grow, and for this purpose, holding the mouse click pressed over time is the effort. So I am thinking now, that maybe a smartphone would ideally have some other design of effort, like moving the finger or something.

Anyway, if I would still continue trying to replicate this mouse-logic with the finger touch, would I have to somehow tell the browser something like 'holding touch pressed does not mean selecting an element/this element'?

Many thanks!


Solution

  • On iOS at least you can use -webkit-user-select: none to prevent this behaviour. I tested this out on an iPhone in person.