A keyboard is just an input device, it has no direct relation to standard input as such. The standard input of a program is merely an abstract data stream that is passed as file descriptor 0.
Many programs using standard input take input from the keyboard, but they don't do this directly. Instead, in the absence of instructions to do otherwise, your shell connects the new program's standard input to your terminal, which is connected to your keyboard. That the input comes from the keyboard is not any concern of the program, which just sees a stream of data coming from your terminal.
As for how both keyboards work simultaneously, this work is typically performed at the kernel level, not at the terminal or application level. Applications can either request to get input from one of the keyboards, or a mux of all of them. This representation typically applies to most human input devices, not just keyboards.
If you are using X, or a similar intermediate layer(s) between the kernel and your program, more abstractions may be present, but the basic idea is the same—utility applications typically don't access the keyboard.