Keyboard not functioning well

my HP pavilion g7 keyboard is not working well. the problem is when I switch on the laptop and I press any of the function keys (f1 f2 f3........) the rest of the keys stops working. only the function keys will work.
when I want the rest of the keys to work. I have remove the battery and use my hands to scratch the place where the battery was.
when I do that the keys will work with the exception of the function keys.
when I press in the function keys it will stop working again. so please help me