Boot from a Linux disk (easy to make) and see how the keyboard (both internal and external) behave then.
If OK in Linux, first try System Restore, than a Windows refresh or reset back to factory conditions.

Kees