I have a system with multiple keyboards, and one CPU. The problem is, if person 1 is entering a value from keyboard 1 and person 2 enters the value from keyboard 2 at the same time, the value entered is mixed up. What peripheral can be used so that only one keyboard is active at a time. For example, when keyboard 1 starts typing, keyboard 2 must be disabled until keyboard 1 presses a specific button. [Can a hardware device solve this? Or can it be controlled by using some code in my software?]
OK, I think I have a solution that will be very close to what you originally had in mind: a USB hub with individual port power switches.
By turning power on and off to two keyboards attached to this hub, you can have two keyboards attached to a single computer that don't get in the way of each other - they can be locked out from entering commands until power is restored to their port.
I know that this isn't a hardware answer but TeamPlayer4 (from Dicolab https://www.dicolab.com/) might do what you are looking for. With that, you can use several input devices for several users. So even if typing on keyboard A doesn't disable keyboard B, as far as it is not the same user, keyboard B won't mix up with A ;)