Do you have multiple keyboards enabled in the MAME.ini?
If so, MAME is looking for input from a specific keyboard.
It will say KBD 1, KBD 2, etc where you map the controls in MAME.
Either change it in MAME.ini or just remap the control in MAME to the proper keyboard.
Keep in mind that after you unplug the keyboard, you will no longer have a keyboard 2.