Search code examples
openlaszlolzx

Open Laszlo onkeydown event issue


I need to check whether any key is pressed or not.

I am using this code. When i run this it's not doing anything unless i click on the laszlo screen why is this happening?

<canvas height="250" debug="true">
     <debug height="90%" />
     <handler name="onkeydown" reference="lz.Keys" args="k">
       Debug.debug("key %w %s", k, "down");
     </handler>
    <handler name="onkeyup" reference="lz.Keys" args="k">
      Debug.debug("key %w %s", k, "up");
    </handler>
    <method name="pressA" args="ignore=null">
      Debug.debug("A pressed");
    </method>
     <handler name="oninit">
      var del = new LzDelegate(this, "pressA");
       lz.Keys.callOnKeyCombo(del, ["A"]);
    </handler>


 </canvas>

Solution

  • Now assuming that you mean the SWF runtime, since you are mentioning 3.3. Handling of keydown is managed either by the browser, or by the Flash Plugin in the browser - it's not shared. As long the Flash component does not have the focus, all events are being sent to the browser. Once Flash has the focus, it will try to capture all events, creating a barrier between Flash and the browser.

    On my operating system, Ctrl-o is mapped to opening a file with the browser. With a Flash movie loaded in the browser, if Flash has the focus, the Ctrl-O command will not work. When I click in the location bar, it's working again. There a lots of questions regarding the SWF/browser focus behavior here on SO.