I have this javascript with jQuery to do the job on computer-screens with mouse and keyboard connected:
For starting the selection of text on screen:
$("body").on("mousedown", ".myDiv", async function(e) {
//do something
});
When the selection of text on screen is done:
$("body").on("mouseup",".myDiv", function(e) {
//do something, e.g. windows.getSelection()
});
On a computer screen, it looks like this:
and on mobile screen it looks like:
On mobile, two things are happening that does not happen on computer screen:
- two handles for modifing selection
- a menu for doing stuff with selection
How do I achieve the same result as on computer screen, i.e. how to mimic mouseup-event when using touch to specifically signal to the browser, that i am done with the selection?
I have tried:
$("body").on("touchstart",".myDiv", function(e) {
//do something, e.g. windows.getSelection()
});
$("body").on("touchend",".myDiv", function(e) {
//do something, e.g. windows.getSelection()
});
Thank you!