Hotkey capture in browsers

I am making a SWF application that will run in a browser. And I want to capture the CTRL+F keypress event when the Flex application is in focus.

It works fine in Firefox, but in Opera and Safari, events are captured before Flex applications and Find Dialog tooltips appear.

Is it possible to use the flex application to capture CTRL+F previous browser?

+7
flex actionscript cross-browser
source share
3 answers

I asked this same question recently and played with it.

I came up with this idea on github:

KeyboardEvent Browser Theft with Javascript and Flex

CTRL-F works!

Look at javascript there. Basically, with Safari you can only hear meta keys (ctrl / alt / shift, etc.); it will not allow javascript to hear AZ events if Flash for some reason works. So I just listen to the meta keys in javascript and then call window.focus() in javascript. This focuses on the browser, so you can capture browser keyboard events !. Then I listen to the events of AZ or something else, and pass them to Flex.

The next step is to simply restore focus in the Flex application, wherever it is before, which should be easy.

Cheers, Spear

+2
source share

Maybe add javascript to your html containing swf that would block it. It seems that these browsers handle events in a different order, so I doubt that you can do anything in the Flash player to do this.

0
source share

Where e is the keyboard event:

 if(e.commandKey || e.ctrlKey){ switch(e.keyCode){ case Keyboard.N: // do stuff break; } } 
0
source share

All Articles