[Chicago-talk] distinguishing between tped input and scanned input.

Brian Katzung briank at kappacs.com
Tue Apr 12 19:18:23 PDT 2005

Richard Reina wrote:

> I have a simple script that waits for a user to type
> in or scan in via the barcode scanner a five digit
> number.  Is there anyway to make the program
> distinguish between scanned input and typed input.  If
> the input is scanned I would like the program to not
> wait for return to be pressed.  I tried fooling around
> ReadKey but could not get the program to distingush
> between typed input and scanned input?
> Does anyone know how I can achieve this?
> Thanks,
> Richard

Configuring the scanner to send a return would definitely be the most 
straight-forward if you can find the configuration [what kind of scanner 
is it?], but here are a couple of options:

While not foolproof, especially if buffering issues are a consideration 
(e.g. across a network connection), you can make an educated guess by 
checking the elapsed time between the first and fifth characters.

If it's less than a second, it was probably either scanned or pasted. At 
more than a second, it was probably typed.

Alternatively, you might configure the scanner to send some sort of 
sentinal. Two sentinals that come to mind are a symbology prefix or, if 
you have the option, to use UCC/EAN-128 encoding which will send a 
representation of the FNC1 symbol plus an application id before the data.

   - Brian Katzung
     Kappa Computer Solutions, LLC

More information about the Chicago-talk mailing list