title: How to handle keyboard events in gnome shell extensions?
body: <p>How can I add an event or other method to listen to keypresses on a gnome shell extension? e.g. show a dialog with each key press showing the pressed key?</p>
  
  <p>I can not find any example. The <a href="https://wiki.gnome.org/Projects/GnomeShell/Extensions/StepByStepTutorial" rel="noreferrer">documentation</a> mentions a <code>keyboard</code> module, but with that common name searching is hard.</p>
  
  <pre><code>Class explanation
  ...
  - General utils
     - Keyboard: Manage and define the keyboard events, etc. for gnome shell. 
  </code></pre>
  
  <p>(read above as a quote from the docs linked above. it is styled as code because the quote styling for some reason do not preserve line breaks in this site)</p>
  
  <p>I found some extensions using the bellow code for results similar to what i'm asking, but i, again, failed to find docs for the specific classes and methods:</p>
  
  <pre><code>workViewInjections['_init'] = injectToFunction(WorkspacesView.WorkspacesView.prototype, '_init', function(width, height, x, y, workspaces) {
          this._pickWorkspace = false;
          this._pickWindow = false;
          this._keyPressEventId = global.stage.connect('key-press-event', Lang.bind(this, this._onKeyPress));                                                                                
          this._keyReleaseEventId = global.stage.connect('key-release-event', Lang.bind(this, this._onKeyRelease));
          connectedSignals.push({ obj: global.stage, id: this._keyPressEventId });
          connectedSignals.push({ obj: global.stage, id: this._keyReleaseEventId });
          });
  </code></pre>
  
  <p>Also, no class named <code>keyboard</code> anywhere there...</p>
  
  <p>--</p>
  
  <p>edit1: more searching... i think i may have to use the <code>Clutter</code> api. but again, not much examples or documentation for that. farthest i went was this</p>
  
  <p>edit2: more searching. looking on the gnome shell source code, on the main ui tree, i think the answer is to use the barelly mentioned <code>global</code> object that is available to the extension code. e.g.</p>
  
  <p><code>global.connect('key-press-event', function(if, i, know, the, signature){} );</code></p>