I can only suggest that you check all connections are tight and there are no obvious faults,other than that see if you can borrow another keyboard and see if the fault still occurs or doesn,t.
i could actually be you have spyware/adware/virus thats crashing you computer and stopping your keyboard from working. Reccomend you do a full system scan