KEY_UP event of ctrl key blocks KEY_UP event of &#

2019-04-14 12:56发布

问题:

I am trying to capture Ctrl+C.

I have noticed that many times, there is no KEY_UP event for C key. I believe it happens in cases KEY_UP event for C key should be thrown just before or after KEY_UP event for Ctrlkey.

Why does this happen? How can I catch the KEY_UP for C key?

回答1:

Everything works fine:

    <?xml version="1.0" encoding="utf-8"?>
< s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx">

<fx:Script>
    <![CDATA[
        protected function myButton_keyUpHandler(event:KeyboardEvent):void
        {
            myButton.label="";
            if(event.ctrlKey)
                myButton.label+="Ctrl-";
            if(event.altKey)
                myButton.label+="Alt-";
            myButton.label+=String.fromCharCode(event.keyCode)
        }
    ]]>
</fx:Script>



<s:Button id="myButton" keyUp="myButton_keyUpHandler(event)" />


</s:Application>