Is it possible to track keydown/keyup events in FireFox addons? I would like to implement something similar as following scenario:
- After pressing and holding the modifier key panel appears
- While holding these modifier keys, pressing the other keys will cause some actions with the panel
- When modifier key released, the panel disappears
You would need to register your event listener in each browser window for that. The high-level SDK API don't give you direct access to the browser window however, you will have to use the low-level modules for that, in particular the (currently undocumented)
sdk/keyboard/observer
module. It allows you to listen to key events in all browser windows, so something like this should work:Notes:
sdk/keyboard/observer
module is completely undocumented, it might change or go away completely any time.WindowTracker
from thesdk/window-utils
module which is now deprecated. If you really want to look at browser windows yourself you would now use the (also undocumented)sdk/windows/observer
module which allows listening toopen
andclose
events. The functionisBrowser()
to distinguish browser windows is now available viasdk/window/utils
module. You would also need to usewindows()
function to consider already open windows, the windows observer doesn't do that automatically.