1 Reply Latest reply on May 31, 2017 9:06 AM by sberic

    RegisterKeyEventsInterest Intermittently Not Working?

    sberic Level 2

      Last week my panel was properly responding to keyboard input. I would click into it and could get listener callbacks when hitting certain keys for which I'd registered interest with CEP.

       

      Today I started up Premiere (it had actually been up for quite a while, including while the computer slept, but I've shut it off and turned it on again) and found that the CEP panel would not respond to any of the keyboard events. Pressing just about any key while the panel is focused results in a "boop" sound effect (I'm on a mac) and no response from the panel.

       

      As an example, I'm "registering interest" using:

       

      cs.registerKeyEventsInterest('[{"keyCode": 0x0F}]');  // 0x0F is "r" for the mac.
      

       

      And then adding an event listener with:

       

      document.body.addEventListener('keydown', handleKeyEvent, false);
      

       

      Has anyone else encountered this? What could suddenly cause Premiere Pro to stop properly passing keyboard events on to the panel?

        • 1. Re: RegisterKeyEventsInterest Intermittently Not Working?
          sberic Level 2

          I found the problem. This is not a bug with Premiere Pro, but a bug with the code I'm using. Specifically, I rearranged my strings to be more readable, doing something like the following:

           

          cs.registerKeyEventsInterest(
              '[ \
                  {"keyCode": 0x0F}, \
                  {"keyCode": 0x0F, "ctrlKey": true} \
              ]'
          );
          

           

          This is a multi-line string. Unfortunately, this adds a whole bunch of space characters to the resulting string. See:

           

          [                {"keyCode": 0x0F},                {"keyCode": 0x0F, "ctrlKey": true}           ]
          

           

          Apparently, this interferes with the JSON parsing. By switching to the following, I was able to get keyboard input to work again:

           

          cs.registerKeyEventsInterest(JSON.stringify(
              [
                  {"keyCode": 0x0F},
                  {"keyCode": 0x0F, "ctrlKey": true}
              ]
          ));
          

           

          So a bug existed, just in my own code. Whoops!