Why is my keyboard not working correctly?

My keyboard doesn't work. If I attach it to my tablet, then it just glitches and holds a random key or keys. Ex. dddddddddddddddddddddd or d/d/d/d/d/d/d/d/d/d/d/d/d/d/. Also, my USB input does not always work, sometimes I attach a mouse, but often t doesn't work. Neither does my actual mouse pad that's n the keyboard.. Any ideas of how to fix this without getting a new one?

crwdns2934089:0crwdne2934089:0 crwdns2934093:0crwdne2934093:0

crwdns2934109:0crwdne2934109:0

crwdns2889612:0crwdne2889612:0 0
crwdns2934285:0crwdne2934285:0