I bought a used macbook which does not have some screws of its casing. The buttons of the keyboard stop working at times. Only the power button works. When I restart, it starts to work fine. What could be causing this?
First of all, you bought it used with screws missing, so I'd recommend taking it to a shop or a friend that knows what he's doing to check to make sure all the hardware is there and if so, not damaged.
Second, test a different keyboard on the computer, usb keyboards are all the same, if it hangs still, rule out the keyboard.
If hardware shows fine, and changing keyboard does nothing, the next step, reinstall the OS.