It is extremely difficult to detect since antivirus software will never know whether a user types something with a usual keyboard or a BadUSB device sends keystrokes with malicious commands. This type of hardware attacks is called BadUSB. It could be programmed to act like a keyboard, mouse or whatever USB device you want. For example, this USB stick is in fact an Arduino compatible development board with ATmega32U4 microcontroller. Sometimes a device is not what it looks like. This class of devices includes keyboards, mice and other controllers. The acronym HID means Human Interface Device. The examples from this instructable may also be helpful for educational purposes to develop digital literacy skills and discussing the concepts of pentesting and ethical hacking.
However, you may use it on your own hardware at your own risk. The author reserves the right not to be responsible for any damage or your illegal action caused by the use of this instructable.