Hi
Maybe this helps. It works directly without pressing any Buttons...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns:cm="module.customModules.*"
xmlns:inc="indexIncludes.*"
backgroundColor="#FFFFFF"
initialize="initThis()">
<mx:Script>
<![CDATA[
function initThis(){
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
mx.controls.Alert.show("DOWN -> Code:
"+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey: "+chr(Key.getAscii()));
};
keyListener.onKeyUp = function() {
//mx.controls.Alert.show("UP -> Code:
"+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey: "+chr(Key.getAscii()));
};
Key.addListener(keyListener);
}
]]>
</mx:Script>
</mx:Application>
Cheers,
Christoph
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[EMAIL PROTECTED] Im
> Auftrag von Shanmuga Raja
> Gesendet: Dienstag, 27. September 2005 16:44
> An: [email protected]
> Betreff: Re: [flexcoders] KeyDown event in mx:Application tag
>
> 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: [email protected] [mailto:[EMAIL PROTECTED]
> On Behalf Of Shanmuga Raja
> Sent: Monday, September 26, 2005 6:41 PM
> To: [email protected]
> 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] <mailto:flexcoders-
> [EMAIL PROTECTED]>
>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> .
>
>
> ________________________________
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
>
>
>
>
> SPONSORED LINKS
> Web site design development
> <http://groups.yahoo.com/gads?t=ms&k=Web+site+design+development&w1=Web+si
> te+design+development&w2=Computer+software+development&w3=Software+design+
> and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c
> =5&s=166&.sig=L-4QTvxB_quFDtMyhrQaHQ> Computer software
development
> <http://groups.yahoo.com/gads?t=ms&k=Computer+software+development&w1=Web+
> site+design+development&w2=Computer+software+development&w3=Software+desig
> n+and+development&w4=Macromedia+flex&w5=Software+development+best+practice
> &c=5&s=166&.sig=lvQjSRfQDfWudJSe1lLjHw> Software design and
development
> <http://groups.yahoo.com/gads?t=ms&k=Software+design+and+development&w1=We
> b+site+design+development&w2=Computer+software+development&w3=Software+des
> ign+and+development&w4=Macromedia+flex&w5=Software+development+best+practi
> ce&c=5&s=166&.sig=1pMBCdo3DsJbuU9AEmO1oQ>
> Macromedia flex
> <http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Web+site+design+de
> velopment&w2=Computer+software+development&w3=Software+design+and+developm
> ent&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.si
> g=OO6nPIrz7_EpZI36cYzBjw> Software development best practice
> <http://groups.yahoo.com/gads?t=ms&k=Software+development+best+practice&w1
> =Web+site+design+development&w2=Computer+software+development&w3=Software+
> design+and+development&w4=Macromedia+flex&w5=Software+development+best+pra
> ctice&c=5&s=166&.sig=f89quyyulIDsnABLD6IXIw>
>
> ________________________________
>
> 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] <mailto: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/