Barcode Scanner vs. The Keyboard

We have a text field on our screen and the operator is supposed to scan a barcode with a barcode scanner. The operator can also type into this text field. Our script is in the “keyTyped” event. We only run the code if we receive a “\n” or character return.

The customer wants to know when the operator “types” the barcode vs. “scans” the barcode. Is there a way to inhibit typing and only allow barcode scanning? Ignore the obvious of removing the PC keyboard.

We were thinking of timing, but we’re not really sure on how to do that in script. Typing a 20 character string takes a lot longer than scanning it so that’s one way of knowing the difference. Any ideas?

Thank you!

No, you cannot distinguish the difference between the operator and the barcode scanner on the text field component. Both require focus and both act like keyboards.

Travis is right that you can’t directly distinguish between the barcode scanner and a keyboard, but you might be able to do something along the lines that you were thinking: using the typer’s speed to detect that it has been typed. Maybe keep a timestamp of when the “first” character was typed (when the text’s length goes from zero to 1), and check the difference between that time and the time when enter is pressed, and see if it is beyond some threshold.