You may or may not be running the right card of card scanner. I.e., if your card scanner just simulates keystrokes, you really need some kind of "app" to to be the context of those keystrokes.
If you have the right kind of scanner, there will be an API that will be appropriate for using without an "active app" to capture the keystrokes.
If you are stuck with using the keystroke based reader, probably about all you can do is what you are doing now, but make your app "invisible" to the user, e.g., 0% opacity, etc. but if the user can manipulate the machine to close you invisible app, etc. you will be in a losing battle.