I just ran into this tonight. Avast hooks into the keyboard drivers, from what I understand, and it can hose your machine.
What worked for me was booting into safe mode, uninstalling avast, then running the aswclear program from Avast (make sure you choose the right version in the dropdown box. I didn't and it kept messing up.) Once I ran that, all was good and my keyboard started working again.
Now I need to make a post about all these "unknown devices" in my device manager...