This is an operating system problem. When a new device is plugged in and claims to be a keyboard, it should lock the screen and not be accepted as input until it has typed the user's login password.
The jimrandomh's idea very interesting. The only problem is defining what is the user's login password, but I'm sure it can be solved.
Maybe even don't go with any keyboards to start, only a mouse and an onscreen keyboard and all others have to be approved.
I wonder whether it's smart enough to adapt its keystrokes for non-Windows platforms, or whether it just does random things to peoples' computers in that case?
It's mentioned in the comments.
How would you ever use one of these things as a guest on a computer (eg at a library kiosk)