Python evdev and bar code scanner
I have a following code which I use to catch input from bar code scanner. The problem is in that I want to save whole scanned code in database, but every character of code prints on new line: #!/usr/bin/env python from evdev import InputDevice, ecodes, list_devices from select import select keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX" dev = InputDevice("/dev/input/event10") barcode = "" while True: r,w,x = select([dev], [], []) for event in dev.read(): if event.type == 1 and event.value == 1: barcode += (keys[event.code]) print barcode # sudo ./bar-code