The selectionchange event of the Selection API is fired when the current text selection on a document is changed.
document.addEventListener("selectionchange", function() {
  console.log('Selection changed.'); 
});
 The selectionchange event implements the Event interface. You can use the properties and methods defined on this interface.
| Specification | Status | Comment | 
|---|---|---|
| Selection API The definition of 'selectionchange' in that specification.  |  Working Draft | Initial definition. | 
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari | 
|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | 52 (52) | (Yes) | (Yes) | ? | 
on HTMLInputElement and HTMLTextAreaElement
 |  No support | No support | 52 (52) - [1] | No support | No support | No support | 
| Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | 
|---|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | 52.0 (52) | (Yes) | (Yes) | ? | 
on HTMLInputElement and HTMLTextAreaElement
 |  No support | No support | No support | 52.0 (52) - [1] | No support | No support | No support | 
[1] - Experimental support in Nightly behind the dom.select_events.textcontrols.enabled preference. Support for input and textarea is currently not part of the specification.
    © 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
    https://developer.mozilla.org/en-US/docs/Web/Events/selectionchange