What's wrong with cheap handheld barcode scanners, like this for $17:
https://www.amazon.com/Barcode-Scanner-Symcode-Handheld-Read...
It just acts as a USB keyboard (no drivers needed), so you could easily hook it up to a Rasperry Pi to do what you want.