To type an exclamation mark (!) using virsh send-key, you need to pass the keycode sequence for the Shift and 1 keys, as ! is typically produced by pressing Shift+1 on a standard keyboard.
Command:
virsh send-key <domain> KEY_LEFT_SHIFT KEY_1
Replace <domain> with the name or ID of your virtual machine.
Explanation:
KEY_LEFT_SHIFT presses the left Shift key.
KEY_1 presses the 1 key.
- Together, they produce
!.
If you need to release the keys afterward, you can use:
virsh send-key <domain> KEY_LEFT_SHIFT KEY_1 --release
Note:
- The exact key names may vary slightly depending on your
virsh version or keyboard layout. If KEY_LEFT_SHIFT doesn't work, try KEY_SHIFT or KEY_SHIFT_L.
- For other special characters, you may need to combine modifier keys (e.g.,
Shift, Alt, Ctrl) with the base key.