title: How to detect prefers-color-scheme change in javascript?
body: <p>I can use <code>window.matchMedia</code> to detect whether user is in dark mode, but how to listen dark mode change event?</p>
  
  <p>Is there any API like:</p>
  
  <pre class="lang-js prettyprint-override"><code>window.addEventListener('perfers-color-scheme-change', () =&gt; {
    // do something
  })
  </code></pre>