3 Replies Latest reply on Aug 31, 2018 3:06 AM by WIktor Debski

    TC25 keystroke output not raising javascript keypress event

    Martin Stephenson

      I'm trying to capture barcode data from the internal scanner on HTML5 page without an input field to prevent the android keyboard popup.

       

      The code works perfectly on our TC51, but the keypress event is not fired on the TC25.

       

      The Datawedge configuration is the same on both devices. 

      TC51 Datawedge v6.6.47

       

      Keystroke output : Enabled

      Action key : none

      Advanced data formatting, Basic data formatting : Disabled.

       

       

      The following event has been added to the page

       

          document.addEventListener("keypress", function (e) {

       

              if (e.target.tagName !== "INPUT") {

                  $("#barcodeInputHidden").val($("#barcodeInputHidden").val() + e.key);

       

                  $("#barcode").append(e.key);

                  if (!barcodeTimerRunning) { barcodeTimerStart(); }

       

                  e.preventDefault();

              }

          });

       

          function barcodeTimerStart() {

              barcodeTimerRunning = true;

       

              setTimeout(function () {

                  var barcode = $("#barcodeInputHidden").val();

                  evaluateBarcodeInput(barcode);

       

                  console.log('barcode : ' + barcode);

       

                  $("#barcode").html("");

                  $("#barcodeInputHidden").val("");

       

                  barcodeTimerRunning = false;

              }, 500);

          }