title: Prevent text selection while dragging a mouse
body: <p>I have this following JavaScript code which executes my function, when I press the left mouse and drag it across the screen:</p>
  <pre><code>function MyFunc(e)
  {
     // I copied this part from another SO question
     e.preventDefault();
     e.stopPropagation();
     e.cancelBubble = true;
     e.returnValue = false;
     // This should cancel out all default actions, should it not?
  
  
    return false;
  }
  
  document.addEventListener('mousemove', MyFunc false);
  </code></pre>
  <p>What this is supposed to do is, that when the mouse is dragged across the screen (while the left button is pressed, then it prevents text  (or any other elements)  from being selected. But the reality is, that it does nothing. The function is getting executed, which I checked with <code>console.log</code>, but it does not prevent text selection.
  I can't figure out what am I doing wrong here.</p>
  <p>What I'm using right now is this:</p>
  <pre><code>window.getSelection().removeAllRanges();
  </code></pre>
  <p>This works and forcefully cancels the selection, but that is pretty ugly solution and I don't understand why the code above doesn't work.</p>