From what I've seen, USB-based attacks such as RubberDucky need to be able to open a terminal and then execute commands from there, usually to download and then install malware or to open a reverse shell.
Is this how most, if not all USB-based infections operate? Would being able to detect and prevent keystroke injection ensure I would be safe from USB-based malware attacks?
If at all relevant to the question, key combinations used to send signals to the shell would be caught and detected alongside regular keystrokes.
edit: I am mostly concerned with USB-based attacks whose purpose is to infect a machine with malware and/or to open a backdoor through which manipulate the system.
In the case of a reverse shell being opened, will the attack/er still rely on executing commands, i.e., assuming that on the system in question, there was only one terminal open or available will I be able to see keystrokes if this attack were taking place?
In the case of data-exfiltration, would there be ways for the malware on the hardware to mount the partition/filesystem and then copying the files without being able to enter keystrokes?