Neither my regular keyboard or on screen keyboard will work

My keyboard attached to my laptop worked fine for years. Then it got to where every once in awhile the enter key or space key would stop working for a few minutes, then all the keys for a few minutes, and now it's at a point where the entire keyboard stops working more often than not.

However, my on screen keyboard is doing the exact same thing. If the space and enter keys on my real keyboard aren't working, space and enter won't work on the on screen key board. If none of the keys are working on my regular keyboard, none of the keys will work on my on screen keyboard. If the regular keyboard is working fine, the on screen keyboard works fine.

I don't see how it could be a hardware issue with the keyboard if it's affecting the on screen keyboard in the same way.

I've tried updating the driver, doing virus scans, etc. and I can't figure out the problem.

Has anyone else had this problem, or does anyone have any suggestions on fixing it?