When you troubleshoot an issue of keyboard shortcut not working in virtual machine, before proceeding with advanced troubleshooting, please check two important options which are influence on keyboard behavior in virtual machine:
- 'Send system shortcuts' (Parallels Desktop preferences -> Shortcuts). You will find description of this option there in configuration window.
It is recommended to set this option to 'Always' if some keyboard shortcut is not working in the virtual machine.
'Optimize for games' (virtual machine configuration -> Hardware -> Mouse & Keyboard)
When 'Don't optimize for games' option is enabled - an event will be send to virtual machine only once after pressing a modified key.
- When 'Optimize for games' option is enabled - an event will be send to virtual machine all the time a modifier key is pressed.
ADVANCED TROUBLESHOOTING. Performance counter
All keyboard input is sent to VM in 2 stages:
stage 1 - event has been received by Mac OS (client)
stage 2 - event has been received by prl_vm_app
To monitor how event is send to prl_vm_app please use performance counter, which shows you precise lifetime keyboard activity in virtual machine.
Now, to run performance counter please execute the following command in Terminal:
prl_perf_ctl -s hidhook -l 1
The following counters are available there (refreshed every second):
action.acted 0 action.delayed 0 action.ignored 0 keyboard.dropped 0 keyboard.grabbed 0 keyboard.hooked 0 keyboard.injected 0 keyboard.processed 0 keyboard.sent 0 mouse.grabbed 0 mouse.hooked 0 mouse.injected 0 mouse.processed 0 mouse.sent 0
When you focused on Mac OS X - all the counters show no activity (all zeros). But when you switch focus to virtual machine - keyboard.grabbed now shows static change in its index.
- keyboard.grabbed 1 - 'Send system shortcuts' option is set to 'Never' (or 'On condition' for Windows/Linux guest OSes)
- keyboard.grabbed 2 - 'Send system shortcuts' option is set to 'Always' (or 'On condition' for guest MacOS)
Then, when you press any button while focused in virtual machine you see that the following counters changed:
keyboard.injected 2 keyboard.processed 2 keyboard.sent 2
2 is a minimum index: one event for 'key up' event, 1 event for 'key down' event. If you press multiple keys, these indexes will raise.
Now, again, about using modifier keys:
All modified input event has two actions:
action 1 - modifier key down (key is pressed and held)
action 2 - modifier key up (key is released)
- When 'Don't optimize for games' option is enabled:
action 1(on modifier press):
action.delayed 1 keyboard.injected 1 keyboard.processed 1 keyboard.sent 0
This means that input event is now held in key action engine (action.delayed=1) - and no input has been sent to guestOS.
action 2(on modifier release):
action.delayed 0 keyboard.injected 1 keyboard.processed 1 keyboard.sent 2
Now guestOS finally received an input (keyboard.sent=2)
- When 'Optimize for games' option is enabled:
action.delayed 1 keyboard.injected 1 keyboard.processed 1 keyboard.sent 1
This means that an input event has been sent to guest OS (keyboard.sent=1) and also delayed for action 2 (action.delayed=1)
action.delayed 0 keyboard.injected 1 keyboard.processed 1 keyboard.sent 1
This means that input event had been sending to guest OS during all time when user was pressing the key.
NOTE: a CMD button behaves differently. When you hold CMD - no action is delayed, no changes on performance counters are displayed, but an input event is sent to guest OS.
'Send system shortcuts' set to 'Always' + 'Don't optimize for games' enabled.