title: Using js, is it possible to prevent a text selection from extending when shift-clicking elsewhere
body: <p>Please do not report this question as a duplicate. I have seen similar questions on stackoverflow, but they don't answer my specific need.</p>
  
  <p>I have some text selected and highlighted on a web page and I'd like to be able to shift-click away from the selected text without extending the selection of text.</p>
  
  <p>I have created a function that sets the variable shiftkey to true whenever the shift key is pressed and I have another function that gets called on a mouse click. The latter function tests if the shiftkey var is set to true to determine if I have a shift-click event. If so, I thought e.preventDefault(); 
  would prevent extending the selected text, but it doesn't!</p>
  
  <p>Using </p>
  
  <pre><code>document.getElementsByTagName("body").style.userSelect = "none";
  </code></pre>
  
  <p>followed by </p>
  
  <pre><code>window.getSelection().toString();
  </code></pre>
  
  <p>and finally </p>
  
  <pre><code>document.getElementsByTagName("body").style.userSelect = "auto";
  </code></pre>
  
  <p>doesn't work either!</p>
  
  <p>Any ideas how this can be made to work?</p>