if you mousedown on the button the keydown event gets triggered. 
i dont know why this is the case (had this problem as well),  but a 
workaround do the following

<mx:Application initialize="startUp()">

<mx:Script>
function startUp()
{
  Key.addListener(this);
}

function onKeyDown():Void
{
  alert(Key.getCode());
}




--- In flexcoders@yahoogroups.com, Shanmuga Raja <[EMAIL PROTECTED]> 
wrote:
> Hi,
> 
> Any idea why the KeyDown event in the mx:Application Level is not 
trapped
> properly.
> Here is the code snippet. Please find a detailed explanation of 
the problem
> in this chain of mails.
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
> keyDown="keyEvt(event)">
> 
> <mx:Script>
> <![CDATA[
> function keyEvt(event) {
> alert('Key Event Trapped');
> if( Key.isDown(112) ) {
> alert('F1 pressed');
> }
> }
> ]]>
> </mx:Script>
> <mx:Canvas width="550" height="200" backgroundColor="#0099FF">
> <mx:TextInput id="tBox" x="177" y="44"/>
> <mx:Button label="Hullo" id="but" x="227" y="86" />
> </mx:Canvas>
> </mx:Application>
> 
> Thanks & Warn Regards,
> Raja
> 
> On 9/26/05, Abdul Qabiz <[EMAIL PROTECTED]> wrote:
> >
> > You can not trap all function keys if your flex application is 
running in
> > browser. There are various JavaScript hacks, which can trap 
keyboard
> > shortcuts reserved by various browsers. But it is not pretty 
straight
> > forward.
> >  -abdul
> >
> >  ------------------------------
> > *From:* flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] *On
> > Behalf Of *Shanmuga Raja
> > *Sent:* Monday, September 26, 2005 6:41 PM
> > *To:* flexcoders@yahoogroups.com
> > *Subject:* [flexcoders] KeyDown event in mx:Application tag
> >
> > Hi,
> >
> > I am trying to use KeyDown event in mx:Application level to trap 
Function
> > Keys (F1,F2,etc.).
> > I have the following 2 problems:
> >
> > 1. The KeyDown event does not get triggered the first time page 
is loaded,
> > but after I click on the button the key events are triggered.
> > I have attached event.mxml which has this problem. The same code 
works
> > properly if I use mouseDown instead. The mouse events are 
triggered and
> > trapped properly. Please help me out if I had done something 
wrong in this!
> >
> > 2. I want to trap all the Function keys and override the default 
actions
> > of the Browser. For example I want to Set focus to a textinput 
on click of
> > F1 key. I am able to get handle to the function key event in the
> > actionscript but the Windows Help page also loads in IE.
> > Is there any way using Actionscripts to override this behaviour?
> >
> > Thanks & Warm Regards,
> > Raja
> >
> >
> >  --
> > Flexcoders Mailing List
> > FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com
> >
> >
> >  ------------------------------
> > YAHOO! GROUPS LINKS
> >
> >
> >    - Visit your 
group "flexcoders<http://groups.yahoo.com/group/flexcoders>"
> >    on the web.
> >     - To unsubscribe from this group, send an email to:
> >    [EMAIL PROTECTED]<flexcoders-
[EMAIL PROTECTED]>
> >     - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> >    Service <http://docs.yahoo.com/info/terms/>.
> >
> >
> >  ------------------------------
> >




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to