Most all barcode scanners emulate as an USB keyboard, so you need to be looking for how to capture keyboard inputs.
Check out global keyboard hook/Raw input Capture keyboard input. Or search for other answers about global keyboard capture.
If you want to use the users normal keyboard elsewhere , then you need to get creative. I've used luamacros to do this before, however its been discontinued.
The key is that luamacros can driver inject based on vendor id , so it can capture only the keyboard of the barcode scanner.Its not a pretty solution at all cause you need to use a different language( Lua ) and you need to babysit it too( start it up , make sure it does not lose its binding etc) and also integrate it with your application.