I have a window in which there is a text field. The user may enter, but may not enter data in the text field. The program window allows you to draw different shapes. At any time, such keys as Tab and Enter can be pressed. A QR-code scanner that simulates keystrokes on a keyboard is also connected to a computer via a USB port. It is also possible to use other types of scanners, for example, wireless scanners. The code read by the scanner will be used to validate the data. How can I distinguish the input of the QR code scanner from the keyboard input? On the Internet, I found information that the scanner enters characters at a much higher speed, man from the keyboard. In my case, the interval between character input scanner 118-121 ms. On the other hand, if I just knock on the keyboard, the characters will be entered faster. To get the text entered from the scanner or keyboard, I used the TextInput event. Does anyone have any ideas on this?

  • Do you have the same validation of data on the code goes according to a certain format, for example, if it is a hash, then a certain set of characters is certain? Make a keyboard interception (only in the form or global) and read the data into the buffer, if the buffer is filled for a certain time, then throw it on the data validation. - Gennady P

1 answer 1

It is impossible to distinguish in any way, since the scanner imitates the keyboard. Look, maybe your scanner may work in a different mode. In another question, I described various modes of operation: How to catch a string from a barcode scanner?

Or, alternatively, when connecting a scanner, indicate its port in the program and listen to it.