VirtualBox Mac - Is it possible re-map a key for a VM
Because Mac is dumb and tries to be different, common shortcuts such as ctrl+c and ctrl+v are cmd+c and cmd+v on Mac.
Macs had copy and paste before Windows. Separating control and command means that you don't need additional keybindings for interrupting a process in a shell or going a page down in emacs.
Anyway, you can do that with KeyRemap4MacBook.
You could also save something like this as private.xml:
<?xml version="1.0"?>
<root>
<item>
<name>test</name>
<identifier>private.test</identifier>
<only>VIRTUALMACHINE</only>
<autogen>--KeyToKey-- KeyCode::Z, VK_COMMAND, KeyCode::Z, VK_CONTROL</autogen>
<autogen>--KeyToKey-- KeyCode::X, VK_COMMAND, KeyCode::X, VK_CONTROL</autogen>
<autogen>--KeyToKey-- KeyCode::C, VK_COMMAND, KeyCode::C, VK_CONTROL</autogen>
<autogen>--KeyToKey-- KeyCode::V, VK_COMMAND, KeyCode::V, VK_CONTROL</autogen>
<autogen>--KeyToKey-- KeyCode::A, VK_COMMAND, KeyCode::A, VK_CONTROL</autogen>
</item>
</root>
The test folder has an XML file with all the predefined remappings.
Related videos on Youtube
Erin Drummond
Updated on September 18, 2022Comments
-
Erin Drummond over 1 year
I am running Windows inside VirtualBox on Mac OSX. However, I am frequently copying and pasting/undoing etc using keyboard shortcuts.
Because Mac is dumb and tries to be different, common shortcuts such as ctrl+c and ctrl+v are cmd+c and cmd+v on Mac. This creates a problem because I keep trying to use mac-style shortcuts in the VM, or windows-style shortcuts on the Mac (my workflow is, do ASP.NET dev in the VM, but use the Mac hosts browser).
What I would like to be able to do is make VirtualBox send "Command" key presses as "Ctrl" to the VM, so that I dont have to keep remembering which environment I am in and thinking about which key combination I need to use.
Is this possible?
-
Erin Drummond over 11 yearsThankyou for your answer. Does this software permanently reassign Command to Control? I only want the reassign to happen while the mouse is over the VirtualBox window (I run VirtualBox in 'auto capture host keyboard' mode).
-
Jack Frost over 9 yearsExcellent answer, It's preferable to do this on the Mac host rather than mucking w/ Windows registry settings per box. @ErinDrummond the highlighted line in the GUI states, "only in virtual machine"
-
Arnaud over 8 yearsVery useful. I --systematically-- get command and ctrl wrong when I switch from the mac to the VM, and back. Today the soft is called Karabiner. PS: How do we convince VirtualBoxVM's developpers to include this option in their program?
-
DiegoDD about 7 yearsKeyRemap4MacBook (now called Karabiner) no longer works in MacOS Sierra. Any other options to achieve the same thing?
-
karfus almost 5 yearsAs of July 2019, @DiegoDD's comment above appears no longer valid...Karabiner installs successfully on Sierra (and Mojave)
-
ybull over 3 years0 That renamed app "Karabiner" appears to be actively maintained. It is hosted here karabiner-elements.pqrs.org and even says it already supports Apple Silicon and OS Big Sur.