title: Electron: How to dectect if app is in unfocused / in background
body: <p><strong>Story:</strong></p>
  
  <p>I'm building an app with electron. This app receives events from the server and displays them. At the same time, the app assumes the events are seen by the user and informs the server.</p>
  
  <p>Let's say, the user changed to another window (e.g. web browser, mail). In that case I don't want the app to still confirm events as seen.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>How can I detect if an electron app is unfocused? The solution should work for Windows and macOS.</p>