Why Are My iMac Wireless Keyboards Malfunctioning? Here's The Fix.
Have you tried using a new wireless keyboard to rule out keyboard issues? Depending on how old they are, it may have reached past their time.
If they are connected using Bluetooth, I would set it to “forget” them and reconnect. If it’s via a USB dongle, do you have another port to test them?
It may also help to test the keyboards on another computer to see if they work. Did you try this Apple troubleshooting guide?https://support.apple.com/en-us/HT204540