Note that there are some explanatory texts on larger screens.

plurals
  1. POCapturing Cmd-C (or Ctrl-C) keyboard event from modular Flex application in browser or AIR
    text
    copied!<p>It seems that it is impossible to capture the keyboard event normally used for copy when running a Flex application in the browser or as an AIR app, presumably because the browser or OS is intercepting it first.</p> <p>Is there a way to tell the browser or OS to let the event through?</p> <p>For example, on an AdvancedDataGrid I have set the keyUp event to handleCaseListKeyUp(event), which calls the following function:</p> <pre><code> private function handleCaseListKeyUp(event:KeyboardEvent):void { var char:String = String.fromCharCode(event.charCode).toUpperCase(); if (event.ctrlKey &amp;&amp; char == "C") { trace("Ctrl-C"); copyCasesToClipboard(); return; } if (!event.ctrlKey &amp;&amp; char == "C") { trace("C"); copyCasesToClipboard(); return; } // Didn't match event to capture, just drop out. trace("charCode: " + event.charCode); trace("char: " + char); trace("keyCode: " + event.keyCode); trace("ctrlKey: " + event.ctrlKey); trace("altKey: " + event.altKey); trace("shiftKey: " + event.shiftKey); } </code></pre> <p>When run, I can never get the release of the "C" key while also pressing the command key (which shows up as KeyboardEvent.ctrlKey). I get the following trace results:</p> <pre><code>charCode: 0 char: keyCode: 17 ctrlKey: false altKey: false shiftKey: false </code></pre> <p>As you can see, the only event I can capture is the release of the command key, the release of the "C" key while holding the command key isn't even sent.</p> <p>Has anyone successfully implemented standard copy and paste keyboard handling?</p> <p>Am I destined to just use the "C" key on it's own (as shown in the code example) or make a copy button available?</p> <p>Or do I need to create the listener manually at a higher level and pass the event down into my modular application's guts?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload