title: Can an Electron JS App on MS WIndows in the system tray listen for keyboard events and launch popup windows?
body: <p>I need to build a program that can run on MIcrosoft WIndows which will be a system tray app.  It needs to sit running in the tray and listen for keyboard presses.  When a mapped key is pressed it will need to open a popup panel which will list and show software shortcuts which when clicked will open the selected software and close the popup window.</p>
  
  <p>It is basically an app launcher which will show a list of software dependent on which keyboard key mapping was triggered.  For example keyboard mapping 1 would show software shortcuts in the popup window that are added to an <code>Image editing</code> category.  Another key would open the same window but show software shortcuts for <code>text editing</code> and so on.</p>
  
  <p>As I am a web developer (PHP and JavaScript).  Building a true Windows C++ or C# style app is out of my abilities!</p>
  
  <p>This is where the software called <strong>Electron</strong> which allows to build cross platform desktop apps using web languages (JS, HTML, CSS) might be able to build what I need and allow me to do it myself!</p>
  
  <p>Electron - <a href="http://electron.atom.io/" rel="nofollow noreferrer">http://electron.atom.io/</a></p>
  
  <p>So the Electron app would need to:</p>
  
  <ul>
  <li>Sit in tray and listen for key presses</li>
  <li>When a mapped key is detected it would need to open a popup window with the category of software items associated with that key</li>
  <li>When software in the popup is clicked on, it needs to open that software and close the popup window.</li>
  <li>When no software is clicked on and a click hapens anywhere else on the screen it needs to close that popup window.</li>
  </ul>
  
  <p>It would then also need a basic settings panel window to   </p>
  
  <ul>
  <li>assign keyboard shortcuts to categories  </li>
  <li>add/delete software shortcuts storing the <strong>software name</strong>, <strong>file path</strong>, <strong>category</strong>, and optional <strong>icon or image</strong></li>
  </ul>
  
  <hr>
  
  <p><strong>Question</strong></p>
  
  <p>My real question now is.  Can an Electron app that is running in the windows task tray listen for keys and also able to open and close the popup windows?</p>
  
  <hr>
  
  <p>Below is an image to show how basic the popup windows need to be.  It is just a matter of being capable of opening a popup window from the tray app without a main window ap being opened or focused</p>
  
  <p><a href="https://i.stack.imgur.com/WdKEL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WdKEL.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <h2>UPDATE</h2>
  
  <p>I have confirmed that an Electron app in the system tray can listen for keyboard events and launch windows when they happen using <a href="http://electron.atom.io/docs/api/global-shortcut/" rel="nofollow noreferrer">globalShortcut</a>.</p>
  
  <p><strong>globalShortcut</strong> <a href="http://electron.atom.io/docs/api/global-shortcut/" rel="nofollow noreferrer">http://electron.atom.io/docs/api/global-shortcut/</a></p>
  
  <blockquote>
    <p>Detect keyboard events when the application does not have keyboard
    focus.</p>
  </blockquote>
  
  <p>I am not sure yet about:</p>
  
  <ul>
  <li>opening other program shortcuts from my app</li>
  <li>closing the popup on selection of item or window losing focus</li>
  </ul>