Need more info. Are you in MacOS 9 or X? What programs are running? Is it the built in keyboard or a USB one? If you answer these questions I think more ppl can help you. From what it sounds like you should call Apple Tech and maybe get a replacement keyboard if there is a bad connection.
JLB