[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

keylistener doesn't work before textfield has got focus

I have a flash movie with a keylistener on the Enter key.

But initially when loading the flash movie, the keylistener doesn't work.
Only when a textfield have had focus - the keylistener start working.

I have tried putting a 'Selection.setfocus("myTextField"); in the beginning of the actionscript - but that doesn't help.

Is there a enable the keylistener in another way.
0
sotea
Asked:
sotea
1 Solution
 
Dushan De SilvaCommented:
You can have an idea from following solution.

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21844335.html

BR Dushan
0
 
Aneesh ChopraCommented:
here is the code to listen enter key press;


-----------
var myListener = new Object();
myListener.onKeyDown = function()
{
      if (Key.getCode()==Key.ENTER)
      {
            trace("enter pressed");
      }
};

Key.addListener(myListener);
-----------

IMPORTANT: to test this code you must have to disable the Keyboard shortcuts
do the following to disable it
:

after pressing ctrl+enter...
click the "control" menu on running swf menu, and click the "disable keyboard shortcuts" option from the menu

now you can test that enter will be tracable globally....

Rgds
Aneesh


Rgds
Aneesh
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now