在Firefox扩展中收听keydown / keyup事件 - addon-sdk

时间:2014-03-26 18:07:06

标签: javascript events firefox firefox-addon

我们如何跟踪使用addon-sdk创建的FireFox插件中的keydown / keyup事件。此页面上给出的解决方案已过时(已弃用)FireFox SDK keydown / keyup events我只想更改密钥上的变量值并按下键:

// Event handlers
function onKeyDown(event) {
  if (e.keyCode == 45)
    enableAddon = false;
  else
    enableAddon = true;
}
function onKeyUp(event) {
    enableAddon = true;
}

我尝试过自己的东西,但我不知道:

var { on, off } = require('sdk/event/core');
var delegate = {

  onLoad: function(window) {
      on(window, "keydown", onKeyDown);
      on(window, "keyup", onKeyUp);
  },
  onUnload: function(window) {

      off(window, "keydown", onKeyDown);
      off(window, "keyup", onKeyUp);
  },
  // what next, how to find and keep track of windows
};

0 个答案:

没有答案