go to the device manager
activate the menu option "show hidden devices" or "show disconnected devices" or so - I don't know how it is named in English.
click on the plus before USB to show all USB devices
take a good look at the symbols in front of all lines - some symbols should be full, others should be "ghosted".
remove the lines of the ghosted drivers - this will remove the registration of those devices that are currently not detected.
repeat this (remove ghosted lines only) for all other sections of input devices (keyboard, mouse, HID) as well as drives and volumes
do NOT remove any line with a full symbol.
Test if the problem is gone, but do not yet change port if it isn't.
If the problem still happens, remove but do not reconnect your USB keyboard.
Now the device manage should again contain a few ghosted entries from your USB keyboard - remove them as well (right-click with mouse as you have no keyboard left)
Now check if there is any keyboard left in the device manager. If yes (possible on a laptop with integrated keayboard) then test if that keyboard now works correctly. If there are any keyboards still listed even with all physical keyboards removed, then remove them as well - they're wrong.
If you removed fully displayed keyboard registrations while your keyboard was disconnected, then select a refresh/search for new hardware BEFORE connecting the keyboard. There should be nothing reappearing - if it does then you should remember that one because it is most likely the cause of the problem.
After this, reconnect your USB keyboard and everything should work from now on.
If not or if something is not as I described, report the details here.