Force barcode scanned input to textfield

What is the best way to ensure the user has scanned a barcode into a text field rather than typed it in? I am considering looking at the time between entry of the first and last characters. Don’t have a scanner here so will have to go to the site to see if scanning fires the key down event. This is for an API 1 app. Any suggestions will be most appreciated.

do measurement in KeyDown event. Store ticks between each key “pressed” and compare.

I do all the scannings without textfields - I read keys from barcode in KeyDown event entirely.

1 Like

Unless you put in the work to closely integrate with them, handheld barcode scanners behave like keyboards. There’s no way to distinguish between identical text typed or scanned.

However, you could program the scanner to emit special keyboard codes before and after the scanned data. I’ve done this in the past, usually with some nonsense keystroke like Control-2. Your code can watch for these keystrokes and behave accordingly. However, this does require that any scanner used be programmed correctly.

You could also require the user to scan a static barcode on the screen that would tell your application that a scan is coming, and then the actual barcode.

1 Like