How to enable CNTRL-T tab in Flash

We’ve all been there.  Casually browsing online, viewing some Flash powered site. We see something and we want to Google or Wikipedia it. So we hit CNTRL-T.

Brain Crash!  Nothing happens and it seems like our brain is just hanging there in a suspended state waiting for the event to complete – but it never does.  Finally some try/catch error handling in our brains goes something like this.

Try CNTRL-T
Catch (failed to launch tab)
If Flash
Go Duh!
Click URL Bar
CNTRL-T

It’s always bothered me as I do not understand why this is so. Yes, I understand Flash is sandboxed. But come on…usability. Can’t anything be done?

Yes! Sort of…

Below is code to facilitate creating a new tab window. It’s not the prettiest solution, nor is it a complete solution. But blast it – it’s a START!

First you will need to listen for the “applicationComplete” event. Place the following code in your <s:Application> tag.

applicationComplete=”appCompleted()”

Next create a <fx:Script> tag and place the following code inside:
import flash.events.Event; //Imports Event class.
//On application complete event adds a listener to stage which listens for the key stroke down event.
private function appCompleted():void{
stage.addEventListener(KeyboardEvent.KEY_DOWN, monitorKeyStroke);
}
//Function called on key stroke down event. Evaluates keystroke, if CNTRL-T, launches a new tab.
private function monitorKeyStroke(event:KeyboardEvent):void{
if((event.charCode == 116) && (event.ctrlKey == true)){
ExternalInterface.call(“function newTab(){window.open()}”)
}
}

***

Please note, I have not evaluated this on the Mac platform now that I no longer have access to an OS X machine.

Advertisements

2 Responses to “How to enable CNTRL-T tab in Flash”


  1. 1 Adrian Parr December 6, 2009 at 7:13 am

    Hi,

    Yeah, it’s really annoying isn’t it.

    BTW, your if statement should look like …

    if((event.charCode == 116) && (event.ctrlKey == true)){

  2. 2 Pavel December 6, 2009 at 9:47 am

    Just wondering why we have to hack it in first place. this is the same annoying thing like “great” flash player update. why developers should take care of it?!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




December 2009
M T W T F S S
« Nov   Jan »
 123456
78910111213
14151617181920
21222324252627
28293031