If the keys are working outside of mame then they are just not configured properly within mame. Start up a game, hit the "tab" key and go to input general. If by button 5 and 6 you mean the coin/ credit buttons then go into other controls> scroll down to credit 1 and hit enter then assign button 5 and same for 6. If you mean player button 5 and 6 then go into player one controls and set them in there.