See, I think people might be misunderstanding key repeat. As I understand, not sure if I am correct, what key repeat is is the longer you hold down a button you get the character of that key repeated, not the keystroke. I think mame uses the keystroke, not key input? Would I be correct in that?
I can't speak for the MAME guys, but keyrepeat does the following:
[KEYMAKE]{typematic delay} [KEYMAKE]{typematic delay}[KEYMAKE]{typematic delay}[KEYMAKE]{typematic delay}[KEYBREAK]
This means that your keyboard generates a "key down", waits for a time period based on the typematic delay, then continues to generate key downs at the same intervals until you release the key. At that time, a "key up" is generated.
Unless MAME is turning off key repeat, which is entirely possible as it is controlled by the PC, it would have to keep a temporary record of keys that have been pressed and only act on those keys in the event of a release.
At least that's how I would have done it

RandyT