How can I fix my USB keyboard that keeps on chattering whenever I plugged in my laptop to its charger?

I'd bet it's the rectifier in the cheap PSU, being only half wave. Might fix if you earth it properly… or not, if it's not earthable.

Solution, really, would be a good PSU.