开发者

XUL shortcut keys

开发者 https://www.devze.com 2022-12-18 13:33 出处:网络
I am developing a Firefox add-on, and for that I have used overlay, now I want that if somebody presses the key like control+j it should open my extension, and if somebody presses ctrl+space it should

I am developing a Firefox add-on, and for that I have used overlay, now I want that if somebody presses the key like control+j it should open my extension, and if somebody presses ctrl+space it should execute a J开发者_高级运维avaScript function.

I tried this:

<keyset id="mainKeyset">
    <key id="keyOpen" keycode="VK_J" oncommand="document.getElementById('menuboard').showPopup(document.getElementById('mypanel'), -1, -1, 'popup', 'topleft', 'bottomleft');"/>
    <key id="keyExecute" modifiers="control" keycode="VK_SPACE" oncommand="javascript:myfucntion();"/>
</keyset>

But where it's not working what I am missing can anybody help me, please.

Thanks,

Jaswant


I don't know why, but using key instead of keycode works:

<keyset id="mainKeyset">
  <key id="key1"  modifiers="control" key="j" oncommand="alert(1)"/>
  <key id="key2"  modifiers="control" key=" " oncommand="alert(2)"/>
</keyset>

Generally it would be better if you provided a simplified testcase with simple code in oncommand and said that oncommand code doesn't appear to be called instead of just saying "it's not working".

And oncommand="javascript:...." makes no sense. Lose the "javascript:" prefix.


Yeah Nickolay,

You were right, key worked instead of keycode.

<key id="key1"  modifiers="control" key="j" oncommand="alert('1')"/>

In programming sometimes we get unexpected behavior.

Cheers,

Jaswant

0

精彩评论

暂无评论...
验证码 换一张
取 消