firefox add-on shortcut does not work anymore

假如想象 提交于 2019-12-06 15:34:09

That code example looks correct, I suspect that there is some code within myfunction() that is failing, so we need more information probably. Try to replace myfunction() with alert("test"), that should work.

Noitidart

Some notes:

Can copy paste this to scratchpad:

var keyset = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'keyset'); //http://forums.mozillazine.org/viewtopic.php?f=19&t=2711165&p=12885299&hilit=mainKeyset#p12885299
//cant use mainKeyset see topic above
var key = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'key');
var props = {
  id: 'key_convert',
  modifiers: 'accel',
  keycode: 'VK_F12',
  oncommand: 'alert("tirggered")'
};
for (var p in props) {
  key.setAttribute(p, props[p]);
}
keyset.appendChild(key);
Services.wm.getMostRecentWindow('navigator:browser').document.documentElement.appendChild(keyset);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!