The problem is that most scanners are configured to act like a keyboard - and there is no way to tell exactly where any particular keypress came from: it could be from a scanner and the next could be a "real" keyboard. Windows doesn't track keypresses like that.
What you need to do is talk to the manufacturers of the actual scanner you are using and find out how to add specific lead-in and tail-out sequences to the codes it provides. You can then detect the start and end of the scanned code, and that lets you "divert" it to anything you want.
When you have the scanner doing that, it's just a matter of previewing all keyboard input at Form level:
Handle keyboard input at the Form level - Windows Forms .NET | Microsoft Docs[
^] Then you can do what you want with the scanned codes!