Does anyone else find it funny that it's seemingly easier to create a robot/hardware solution to press a 5 key than it is to wade through Microshaft's raw input API? 
It won't tell you how to fake raw key input anyway, so yeah definately a waste of time

cyapps: You can read HID devices directly (look at the PacDrive SDK and you will see an example in the PacDrive.dll source code I wrote). But the problem is if it's emulating a keyboard there will probably be a problem preventing the data being processed by the installed keyboard driver.
The best way to trap input from the keyboard is to use a global keyboard hook (search Google for WH_KEYBOARD_LL). With that you can stop all input reaching other apps by "eating the keystroke" which just means not letting it pass through your hooks WinProc function.
Now as for injecting keys into Mame's Raw Input system the way to do it is by writing a dll to:
1. Use SetWindowsHookEx to attach to the Mame process space
2. When you attach to the Mame process API Hook "GetProcAddress"
3. Then in your GetProcAddress hook, hook into RegisterRawInputDevices, GetRawInputDeviceList, GetRawInputDeviceInfo, GetRawInputData.
4. To inject a key send Mame a fake WM_INPUT message which will trigger a "GetRawInputData" call in Mame
6. Inside your GetRawInputData hook you need to inject the actual key
Also you will need to create an appropriate 32 or 64 bit dll depending on the compiled version of Mame because some of the API functions you need to hook into differ between them. Yes this does work because it's how I've done it.
Yes your probably better off using a keyboard hack or something to inject keys into Mame but IMHO the easiest way to go about this whole thing is to prevent the 5 or 6 keys from passing to Mame in the first place using a global key hook. When you recieve an accepted code when someone swipes their card then allow the 5 and 6 keys to pass onto Mame.