Xorg supports remapping keys via xkb. A typical way would be:
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
Option "XkbOptions" "therp:desktop"
Additionally we put the following line into /etc/X11/xkb/rules/base (or xorg in the same dir):
therp:desktop = +therp(desktop)
This teaches Xorg to treat the option string "therp:desktop" namely by resolving it to +therp(desktop).
Further we need to add the line
--p----- -m------ therp(desktop)
to /etc/X11/xkb/symbols.dir
And finally add a file called therp to /etc/X11/xkb/symbols with the following content:
partial modifier_keys
xkb_symbols "desktop" {
key <AD11> { symbols[Group1]= [ parenleft, braceleft ] };
key <AD12> { symbols[Group1]= [ parenright, braceright ] };
key <AE09> { symbols[Group1]= [ 9, bracketleft ] };
key <AE10> { symbols[Group1]= [ 0, bracketright ] };
};
The effect of these lines is that the keys () and [] are swapped on the keyboard. I personally like that as I type round brackets more often and I like them to be accessible without the Shift modifier key.
However, as soon as a key is touched by xkb, it goes dead for VirtualBox. Notice that 0 and 9 wasn't changed, however 0 and 9 don't work even unshifted.
To make it work I have to adjust the layouts manually in the vbox source code and supply vbox with a keymap that resembles my remappings precisely.