Trouble with Cmd-H and Cmd-Q in VB 3.1.2
Posted: 12. Jan 2010, 17:29
Firstly, I wish to express my sincere thanks and gratitude to the developers of Virtual Box. This is an awesome product.
That having been said, I would like to address a keyboard problem that has arisen for me in release 3.1.2, which I believe stems from a fix for bug #5684 http://www.virtualbox.org/ticket/5684
The short story is that I am no longer able to type the Alt+H or Alt+Q keystrokes into my Windows VM; those keystrokes are effectively dead for me. Even when the keyboard is captured, those keystrokes still do not reach the VM.
My keyboard mappings (about which more below) are such that the Cmd key is used as the Alt key in my Windows VM.
Installing the 3.1.2 Guest Additions in the VM does not make a difference.
The release note for VB 3.1.2 states "Mac OS X hosts: re-enabled CMD+Key combinations, even if the Host-Key isn't CMD" which implies that there is now something "magic" about the CMD key which prevents it from being cleanly remapped within a guest. Perhaps I should rephrase that: it prevents the Host key from being cleanly changed to something other than CMD.
I'm guessing (haven't looked at the code yet) that the bug fix has hard-coded keystrokes for Cmd-H and Cmd-Q and looks for those specifically; plus it does so even when the keyboard has been captured.
IMHO this fix, which is essentially about making OS X menu shortcut keys work, should
(a) be disabled when keyboard capture is active, and
(b) read the OS X menu shortcut keys from the menu itself
rather than being hard coded as Cmd-H and Cmd-Q,
thereby honouring changes made via NSUserKeyEquivalents
The rest of this note (a bit of a ramble, sorry about that) explains my position in more detail.
I want a keyboard layout that places the PC Alt key where my fingers expect it to be, namely next to the space bar, which would be the CMD key on my Mac. By default, this is the Windows key within a VM.
In my Windows VM, I use a registry setting (HKLM\System\CCS\Control\KeyboardLayout) to swap the Alt (Alt/Option on Mac KB) and Windows (Cmd on Mac KB) keys. IIRC the default Host key is Left Cmd; I set it in VB preferences to the Left Option key, so that Alt-keypresses in the VM are not executed as VB Host Key actions.
So far so good, except for one final problem, namely the OS X menu shortcut keys in the Virtual Box VM menu, specifically Cmd-H and Cmd-Q. These would invoke the VM Hide and Quit menu items when what I really wanted was to key in Alt+H or Alt+Q to the VM itself. One way around that is to capture the keyboard (tap Host key or use Auto-Capture) but even better, I found I could change the OS X menu shortcut keys to something I was less likely to type under normal circumstances in the VM (by using 'defaults write org.virtualbox.app.VirtualBoxVM NSUserKeyEquivalents ...')
This has worked well up to now: I could have the PC VM's Alt key where I expected it to be, a Cmd-H keystroke in the VM would send an Alt+H to the VM instead of hiding the VM window, and Cmd-Q would send an Alt+Q to the VM instead of raising the VB VM Quit dialogue.
Unfortunately it's broken in VB 3.1.2: Cmd-H and Cmd-Q do nothing at all for me. The VM doesn't see these keystrokes because the Virtual Box VM sends them straight up to its Carbon/Cocoa framework, and they don't do anything there because they are not menu shortcuts (thanks to my NSUserKeyEquivalents changes).
That having been said, I would like to address a keyboard problem that has arisen for me in release 3.1.2, which I believe stems from a fix for bug #5684 http://www.virtualbox.org/ticket/5684
The short story is that I am no longer able to type the Alt+H or Alt+Q keystrokes into my Windows VM; those keystrokes are effectively dead for me. Even when the keyboard is captured, those keystrokes still do not reach the VM.
My keyboard mappings (about which more below) are such that the Cmd key is used as the Alt key in my Windows VM.
Installing the 3.1.2 Guest Additions in the VM does not make a difference.
The release note for VB 3.1.2 states "Mac OS X hosts: re-enabled CMD+Key combinations, even if the Host-Key isn't CMD" which implies that there is now something "magic" about the CMD key which prevents it from being cleanly remapped within a guest. Perhaps I should rephrase that: it prevents the Host key from being cleanly changed to something other than CMD.
I'm guessing (haven't looked at the code yet) that the bug fix has hard-coded keystrokes for Cmd-H and Cmd-Q and looks for those specifically; plus it does so even when the keyboard has been captured.
IMHO this fix, which is essentially about making OS X menu shortcut keys work, should
(a) be disabled when keyboard capture is active, and
(b) read the OS X menu shortcut keys from the menu itself
rather than being hard coded as Cmd-H and Cmd-Q,
thereby honouring changes made via NSUserKeyEquivalents
The rest of this note (a bit of a ramble, sorry about that) explains my position in more detail.
I want a keyboard layout that places the PC Alt key where my fingers expect it to be, namely next to the space bar, which would be the CMD key on my Mac. By default, this is the Windows key within a VM.
In my Windows VM, I use a registry setting (HKLM\System\CCS\Control\KeyboardLayout) to swap the Alt (Alt/Option on Mac KB) and Windows (Cmd on Mac KB) keys. IIRC the default Host key is Left Cmd; I set it in VB preferences to the Left Option key, so that Alt-keypresses in the VM are not executed as VB Host Key actions.
So far so good, except for one final problem, namely the OS X menu shortcut keys in the Virtual Box VM menu, specifically Cmd-H and Cmd-Q. These would invoke the VM Hide and Quit menu items when what I really wanted was to key in Alt+H or Alt+Q to the VM itself. One way around that is to capture the keyboard (tap Host key or use Auto-Capture) but even better, I found I could change the OS X menu shortcut keys to something I was less likely to type under normal circumstances in the VM (by using 'defaults write org.virtualbox.app.VirtualBoxVM NSUserKeyEquivalents ...')
This has worked well up to now: I could have the PC VM's Alt key where I expected it to be, a Cmd-H keystroke in the VM would send an Alt+H to the VM instead of hiding the VM window, and Cmd-Q would send an Alt+Q to the VM instead of raising the VB VM Quit dialogue.
Unfortunately it's broken in VB 3.1.2: Cmd-H and Cmd-Q do nothing at all for me. The VM doesn't see these keystrokes because the Virtual Box VM sends them straight up to its Carbon/Cocoa framework, and they don't do anything there because they are not menu shortcuts (thanks to my NSUserKeyEquivalents changes).