Brakebusk Brakebusk - 9 months ago 63
Python Question

Python: Reading input when finished typing

I am writing a python script which is going to take use of input from a barcode scanner. As it stands, the barcode scanner acts as a keyboard, writing the scanned code into the console (such a code may for ex. be: 123456789). Is there a way to automatically read the inputted code when the scanner is finished writing? Right now the user has to press enter any time a code is scanned. Are there any existing libraries for barcode scanners that i have yet to come accross?


Reading the input with raw_input will not work because it waits for the user hitting the return button. However, reads single characters from the standard input. Use this function and check if the characters there were already entered are as many as you expect. You find information about read()

Information about read(): sys.stdin works like a file.