Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Check if User input is from Barcode Scanner or Keyboard?

I am creating a p.o.s application for a cafeteria company in which the cashier scans his employee ID and it shows his information for the transaction.

My Problem is, the cashier can also use their keyboard for their input (employee ID) which is very risky.

if employee(true)
   show employee information
   then add orders
else
   Exception

Currently I just hide TexTbox from the UI, click New Button then set cursor focus on it. Then cashier scans employee id. In this part, the cashier can also type via keyboard and continue transaction.

What is the best way to handle this scenario? The rule is only barcode scanner must be use.

Thanks in regards

like image 970
Crimsonland Avatar asked Feb 23 '11 08:02

Crimsonland


People also ask

How do I tell if keyboard input is coming from a barcode scanner?

In order to use the Barcodescanner Keyboard you need to enable it. Do this by opening Android Settings , Language & keyboard and enable the input method named Barcode Keyboard by checking the box. Confirm the security warning (see privacy). After the input method was enabled it must be activated.

Are barcode scanners input devices?

A barcode reader, also called a price scanner or point-of-sale ( POS ) scanner, is a hand-held or stationary input device used to capture and read information contained in a bar code .

Can a barcode tell you who bought it?

ANSWER: No, a barcode does not tell you where an item was manufactured. The number tells you what the item is, who owns the item and which GS1 office licensed the number.


1 Answers

If you have the possibility to modify the scanner configuration you can add some prefix/suffix to the scanned data. Then in the code you can detect those added characters.

If you can't, then only way is Ahmed's - measuring the time of data entry.

like image 128
ufoq Avatar answered Oct 22 '22 22:10

ufoq