Another reason to use QubesOS, where usb devices are connected to a separate virtual machine without any networking. And any usb keyboards are only activated after a confirmation.
upd: Alternatively, for installations with a usb keyboard, this defence is disabled.