hotkeys

  • Revision slug: Mozilla/Add-ons/SDK/High-Level_APIs/hotkeys
  • Revision title: hotkeys
  • Revision id: 502907
  • Created:
  • Creator: wbamberg
  • Is current revision? No
  • Comment

Revision Content

The hotkeys module enables add-on developers to define hotkey combinations.

Usage

To define a hotkey combination, create a Hotkey object, passing it the combination and a function to be called when the user presses that combination. For example, this add-on defines two hotkey combinations, to show and hide a panel:

// Define keyboard shortcuts for showing and hiding a custom panel.
var { Hotkey } = require("sdk/hotkeys");
 
var showHotKey = Hotkey({
  combo: "accel-shift-o",
  onPress: function() {
    showMyPanel();
  }
});
var hideHotKey = Hotkey({
  combo: "accel-alt-shift-o",
  onPress: function() {
    hideMyPanel();
  }
});

 

Revision Source

<p><span class="seoSummary">The <code>hotkeys</code> module enables add-on developers to define hotkey combinations.</span></p>
<h2>Usage</h2>
<p>To define a hotkey combination, create a <code>Hotkey</code> object, passing it the combination and a function to be called when the user presses that combination. For example, this add-on defines two hotkey combinations, to show and hide a panel:</p>
<pre class="brush: js">
// Define keyboard shortcuts for showing and hiding a custom panel.
var { Hotkey } = require("sdk/hotkeys");
 
var showHotKey = Hotkey({
  combo: "accel-shift-o",
  onPress: function() {
    showMyPanel();
  }
});
var hideHotKey = Hotkey({
  combo: "accel-alt-shift-o",
  onPress: function() {
    hideMyPanel();
  }
});</pre>
<p>&nbsp;</p>
Revert to this revision