TC510K scan input stops if user selects and deselect input field.

A simple web app page that logs every time it takes input from the tc510k scanner (configured to give carriage return as action key)

<!DOCTYPE html>
<html>
  <head>
       <script src="lib/jquery/jquery.min.js"></script>
  </head>
  <body>
  <script>
        $(document).ready(function () {

             $(document).keypress(function (e) {

                  console.log("input");
              });
        });
   </script>
  <form action="">
        Form example name: <input type="text" name="fname"><br>
  </form>
  </body>
</html>

Steps to reproduce.

1) Open browser and go to webpage. (tested with default browser, chrome and app webview)

2) Scan barcode -> console will log "input" (as expected)
3) Manually select input field -> selected input field

4) Manually click outside input field -> deselected input field

5) scan barcode -> NO LOG (should log "input")

No input comes from the scanner until user selects something else on the mobile device and then go back to the webbrowser.

 

Any idea why this happends?

Anonymous (not verified)
Hi Carl,You might need to use

Hi Carl,

You might need to use keydown rather than keypress.  I tried the following and found the behaviour seems to happen regardless of whether you are scanning barcodes:

1) Same as your step 1

2) Manually select input field

3) Tap device keyboard

4) Observe "input" is not logged

5) Type on desktop keyboard (assuming connected to device with Chrome debug tools to the desktop) - Observe "input" is output regardless of whether the input field is selected or not.

If you repeat the above with keydown you should see "input" is always output even if the device keyboard is being used.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Carl Klavus
Hi Darryn,First, thank you

Hi Darryn,

First, thank you for your swift reply.

I followed your steps and everything worked well until i noticed a subtile difference, the scanner suffers the same problem with keydown event for actual input, it does not trigger it.

If i follow the same steps as you mention, I.e replace keypress with keydown, and swap console.log("input") with console.log(e.which).
It does capture scannner button press "0", but not what the scanner actually "reads", should be many following charactersCodes, as it was previously when using keypress.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Carl,I've seen something

Hi Carl,

I've seen something similar in the past with the keycodes coming through as 0 but that should have been fixed in Chrome 38+ (http://stackoverflow.com/questions/22473950/keypress-event-not-firing-in-android-mobile​ and 118639 - keydown and keyup events do not have proper keyCode (it's always 0) - chromium - Monorail ) What confuses me is the subject says you are using a TC51 which would have a newer version of Chromium, I presume.  Can you confirm your browser is newer than Chromium 38?  (It should be shown in the user agent)  I guess it is possible that non-GMS TC51s have an older browser but I don't have one here to check.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Carl Klavus
Hi DarrynThe TC51 in question

Hi Darryn

The TC51 in question runs chrome version 54.0.2840.85. Yes it seems to suffer from the same problems that are mentioned in the linked posts. Same with default browser, Android version is 6.0.1.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Strange.  Yes, I see the

Strange.  Yes, I see the behaviour you describe now, it has something to do with the text field on the page - if you load the page and never give focus to the text field then the keys are captured fine but after you give focus to the text field the keys are no longer captured.  I also tried the same logic without JQuery (i.e. onkeydown property of the text field) with no success.

I also see the same behaviour if I just type on the device keyboard so I do not think it is an issue with DataWedge but rather still something wrong with the rendering engine.

At this point I think you'll need to either consider alternatives to your application logic that do not rely on keydown, use a non-blink based browser such as Opera or contact Zebra support for additional help - I suspect those options are given in ascending order of likely hassle.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Carl Klavus
Thanks again for the input, I

Thanks again for the input, I've tried some additional things this morning, changed keyboard to hackers keyboard and tried opera browser, none of it worked unfortunately.
Maybe the better solution is to work with intents instead of javascript keyboard input.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Pietro Francesc...
Hi Carl,Enterprise Browser

Hi Carl,

Enterprise Browser can be a solution in this case as it includes a barcode API and you can avoid to use DataWedge altogether:

About Enterprise Browser 1.6 - Zebra Technologies Techdocs

If you want to stick to DataWedge, Intents are an option (but then you need a way to handle Android intents from the browser).

Best,

Pietro

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Carl Klavus
Hi PietroThanks for the input

Hi Pietro

Thanks for the input.

The app is not accessed by webpage but an android app wrapper with a webview so capturing the intents won't be that much of an issue. Reasons for this is to support scanners with an app that works well cross-platform and even between different scanner companies.

regards,

Carl

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Pietro Francesc...
Understood Carl!maybe than

Understood Carl!

maybe than you can give a look at this blog by my colleague ​ about using DataWedge Intents in a Cordova hybrid application:

New Cordova Plugin for Android Intents | Darryn Campbell's Blog

Not exactly what you're looking for but maybe relevant. Darryn wrote another blog about native Android apps doing barcode scanning on different devices (Zebra, consumer, etc):

Writing Enterprise Android applications that capture barcode data and run on multiple devices | Darryn Campbell's Blog

Ciao

~Pietro

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Carl Klavus
Hi PietroThank you for your

Hi Pietro

Thank you for your help. Darryn's approach for a generic data capture solution is an intressting read. Might be a path we will head in the foreseeable future.

hälsningar,

Carl

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Daniel Lemmon
I've stumbled into the same

I've stumbled into the same issue building an Angular application that is listening to keypress events. I don't think that this is an issue that can be solved by Zebra even. I happen to have another evaluation device (RS30 by CipherLabs) and it suffers from the same problem as soon as a soft keyboard is presented.

My fear is that I'm going to have to create a cordova application to wrap around my hosted Angular app, which is disappointing.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Pietro Francesc...
Hi Daniel,these are the joys

Hi Daniel,

these are the joys and pains of JavaScript... it works till it does not break :-)

We (as Zebra) have done in the past fixes to the chromium engine used in the Android System browser, but this takes time and is not probably the best option as it will fix the issue on a particular device, and it looks like you want to have a solution that works across different devices.

Building a Cordova container could be a solution and in this thread you can find same reference on how to integrate DataWedge with some additional control.

If you want to avoid as much as possible touching the native side of Android, you can give Enterprise Browser a try, but again, this is limited to Zebra devices.

Best,

~Pietro

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anders Grandt
Same Issue

Any solution?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
The latest recommendations on

The latest recommendations on this topic are detailed at https://developer.zebra.com/blog/listening-keypress-events-datawedge

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments