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.

monkey
  • 526
  • 7
  • 21
no one special
  • 1,608
  • 13
  • 32

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ý
  • 7,068
  • 1
  • 21
  • 34