views:

31

answers:

2

Hi Friend,

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 JavaScript 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

+1  A: 

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.

Nickolay
A: 

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

jaswanttak