title: Is it possible to get selectionchange-like events for an input box in Firefox?
body: <h2>How can I get the selected text inside an <code>input</code> box in Firefox?</h2>
  
  <p>This is apparently a fundamental difference in the way that JavaScript works between Chrome and Firefox. To reproduce:</p>
  
  <ul>
  <li>Navigate to www.google.com</li>
  <li>Open JS console</li>
  <li>Type following line: <code>document.addEventListener("selectionchange", () =&gt; console.log(document.getSelection().toString()))</code></li>
  <li>Type "text" into Google search box and do <strong>not</strong> hit enter</li>
  <li>Use the mouse to select different portions of the "text" in the search box</li>
  </ul>
  
  <p>In Chrome, you will see the event raised for selected text within the <code>input</code> element. This is consistent across various web pages that use <code>input</code> fields. In Firefox, the event is raised for selections outside the <code>input</code>, but when the text in the box is selected, no event is raised.</p>
  
  <p>I have not found any explicit reference to this difference in any Mozilla documentation, nor have I found mention of it on any other web page.</p>
  
  <h1>Related but different question</h1>
  
  <p><a href="https://stackoverflow.com/questions/40059087/firefox-web-extension-selectionchange">Firefox Web Extension “selectionchange”</a> is an older question, and the <code>dom.select_events.enabled</code> config attribute is now defaulted to <code>true</code> in FF 56. There is a second config attribute, <code>dom.select_events.textcontrols.enabled</code> that seems like what I'm looking for, but changing that value to <code>true</code> doesn't seem to have any effect.</p>
  
  <h1>Additional info (Edit 1)</h1>
  
  <p>Apparently there isn't even a way to get selected text in a textbox in FF? The following code also doesn't work:</p>
  
  <pre><code>setInterval(() =&gt; console.log(document.getSelection().toString()), 1000)
  </code></pre>
  
  <p>In FF, this will never return the selected text in an input field. In Chrome, it will.</p>
  
  <p>Is this just a feature gap in FF? Is there no other way to extract selected text from a form field?</p>