7 Replies Latest reply on Jan 29, 2015 1:27 AM by LeoTaro

    HTML5 UI is unable to correctly get the information of  key-events .

    Pulluran Level 1

      I have developed a plug-in for Illustrator CC2014.

      But, The Plug-in UI which was built with HTML5, is unable to correctly get the information of  key-events .

       

      As problems following.

       

          0-9 key press       : "keyCode" is "0"

          Shift key press     : "shiftKey"is "false"

          Alt key press        : "altKey"is"false"

       

      Even if acquired at any timing(keydown, keypress, keyup) symptom occurs.

       

      In the Windows, you can get the information of key-events is correct at the same implementation.

      In the case of the browser UI, even in the Mac, I can correctly get.

       

      What causes that can not be acquired key event information is correct on the plug-in?

      Also, If you have any way to get the information of key-events correctly, please let me know.

        • 1. Re: HTML5 UI is unable to correctly get the information of  key-events .
          LeoTaro Level 4

          Do you have some code that shows this problem?

          • 2. Re: HTML5 UI is unable to correctly get the information of  key-events .
            Pulluran Level 1

            Thank you for reply.

             

            When onKeydownEvent is called, the "event.KeyCode" was "0".

            ------------------

            $(function() {

            document.getElementById("textboxComponente").addEventListener("keydown", onKeydownEvent);

            });

            function onKeydownEvent(obj) {

            var keyCode = (event.keyCode >= 96 && event.keyCode <= 105) ? event.keyCode - 48 : event.keyCode;

            var inputStr = String.fromCharCode(keyCode);

            }

            -------------------

            • 3. Re: HTML5 UI is unable to correctly get the information of  key-events .
              LeoTaro Level 4

              Pulluran wrote:

               

              Thank you for reply.

               

              When onKeydownEvent is called, the "event.KeyCode" was "0".

              ------------------

              $(function() {

              document.getElementById("textboxComponente").addEventListener("keydown", onKeydownEvent);

              });

              function onKeydownEvent(obj) {

              var keyCode = (event.keyCode >= 96 && event.keyCode <= 105) ? event.keyCode - 48 : event.keyCode;

              var inputStr = String.fromCharCode(keyCode);

              }

              -------------------

              Shouldn't that be

               

              function onKeydownEvent(event) {

              • 4. Re: HTML5 UI is unable to correctly get the information of  key-events .
                Pulluran Level 1

                I tried the event, but it does not resolve.


                In the windows, onKeydownEvent(event) can get the event information correctly.

                in the Mac, the keyevent information was originally can be get.The problem is that the keyevent information was not the correct information.



                • 5. Re: HTML5 UI is unable to correctly get the information of  key-events .
                  LeoTaro Level 4

                  Pulluran wrote:

                   

                  I tried the event, but it does not resolve.


                  In the windows, onKeydownEvent(event) can get the event information correctly.

                  in the Mac, the keyevent information was originally can be get.The problem is that the keyevent information was not the correct information.



                   

                  "in the Mac, the keyevent information was originally can be get"

                  What does that mean?

                   

                  "The problem is that the keyevent information was not the correct information."

                  The problem seems to be that the event contains no information, keyCode is always zero and shiftKey and altkey are always false.

                   

                  What happens if you try

                   

                  function onKeydownEvent(obj) {

                  var keyCode = (obj.keyCode >= 96 && obj.keyCode <= 105) ? obj.keyCode - 48 : obj.keyCode;

                  var inputStr = String.fromCharCode(keyCode);

                  }

                  • 6. Re: HTML5 UI is unable to correctly get the information of  key-events .
                    Pulluran Level 1

                    I tried the following code, but this problem does not resolve.

                    Do you think there is a problem with the receiving side of the event?

                     

                    i)

                    function onKeydownEvent(event) {

                    var keyCode = (event.keyCode >= 96 && event.keyCode <= 105) ? event.keyCode - 48 : event.keyCode;

                    var inputStr = String.fromCharCode(keyCode);

                    }

                    ii)

                    function onKeydownEvent(obj) {

                    var keyCode = (event.keyCode >= 96 && event.keyCode <= 105) ? event.keyCode - 48 : event.keyCode;

                    var inputStr = String.fromCharCode(keyCode);

                    }

                    iii)

                    function onKeydownEvent(obj) {

                    var keyCode = (obj.keyCode >= 96 && obj.keyCode <= 105) ? obj.keyCode - 48 : obj.keyCode;

                    var inputStr = String.fromCharCode(keyCode);

                    }

                    • 7. Re: HTML5 UI is unable to correctly get the information of  key-events .
                      LeoTaro Level 4

                      What happens if you try this HTML in a web browser and in your plugin

                       

                      <html>

                      <head>

                      <title>Key Test</title>

                      <script type="text/javascript">

                          function init() {

                              document.getElementById("textboxComponente").addEventListener("keydown", onKeydownEvent);

                          }

                          function onKeydownEvent(obj) {

                              var keyCode = (obj.keyCode >= 96 && obj.keyCode <= 105) ? obj.keyCode - 48 : obj.keyCode;

                              var inputStr = String.fromCharCode(keyCode);

                              document.getElementById("result").innerHTML = inputStr;

                          }

                      </script>

                      </head>

                      <body onload="init()">

                      <form action="#">

                      <input type="text" id="textboxComponente"/>

                      <p id="result"></p>

                      </form>

                      </body>

                      </html>