Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture hotkey in browsers

I'm doing SWF application which will run in browser. And I want to capture CTRL+F key pressing event when Flex application is in focus.

In Firefox it works fine but in Opera and Safari browser captures event prior to Flex application and Find Dialog pop-ups.

Is there any way for flex application to capture CTRL+F event prior browser?

like image 302
tefozi Avatar asked Dec 29 '09 04:12

tefozi


People also ask

What is the shortcut for capture?

Take the Screenshot by using the Windows + Shift + S keyboard shortcut. If you're using Windows 10, press Windows + Shift + S at the same time to capture a portion of your screen and copy it to your clipboard.

How do I take a screenshot in Firefox browser?

Firefox ScreenshotsRight-clickHold down the control key while you click on an empty part of the page and select Take Screenshot. Alternatively, use the keyboard shortcut Ctrl + Shift + S .


1 Answers

I asked this same question recently and have been playing around with it.

I came up with this gist on github:

Browser KeyboardEvent Hijacking with Javascript and Flex

CTRL-F works!

Check out the javascript in there. Basically, with Safari, you can only hear the meta keys (ctrl/alt/shift, etc.); it won't allow javascript to hear A-Z events if Flash is running for some reason. So I just listen for the meta keys in javascript, and then call window.focus() in javascript. That sets focus to the browser, making it so you can hijack browser keyboard events!. Then I listen for the A-Z events or whatever, and pass those to Flex.

The next step is to just restore focus in your Flex app to wherever it was before that, which should be easy.

Cheers, Lance

like image 113
Lance Avatar answered Sep 21 '22 02:09

Lance