0

basically when I click on a word twice in the browser, the word is selected. If three times, whole paragraph is selected. Now, if I have a canvas, and I click on it twice a text below of it will be selected. How can I block this in JavaScript? I mean to not select the text when I click on canvas.

hooman
  • 486
  • 6
  • 19
no one special
  • 1,396
  • 8
  • 24

1 Answers1

3

Use CSS:

canvas {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
Aurel Bílý
  • 6,816
  • 1
  • 21
  • 33