Home » Questions » Computers [ Ask a new question ]

Getting host to capture certain key presses in VirtualBox

Getting host to capture certain key presses in VirtualBox

I'm using VirtualBox on Ubuntu 9.10 with Windows XP as the guest OS.

Asked by: Guest | Views: 41
Total answers/comments: 3
Guest [Entry]

"Pressing the host key (right-ctrl) once appears to allow the next key combination to go to the host machine.

For me, this means I can hit right-ctrl, release, then hit windows+left-ctrl+left to switch desktops"
Guest [Entry]

"I had the same problem, and could only solve it by

first disabling the Auto Capture Keyboard (which was enabled by default), in the File / Preferences / Input menu of VirtualBox
rebooting the VM
enabling again Auto Capture Keyboard
rebooting the VM

I suppose there is a bug in VirtualBox that ignores the initial settings.

Note: I rebooted after disabling the option, the first time I tried to solve the problem, thinking this was the solution (since it's often suggested). It didn't work so I enabled it again and that was fine. So I'm not sure this first reboot step is entirely necessary."
Guest [Entry]

"seems on ubuntu, no Smooth Switch Workspack solution
(without press the HOST key first to release capture)
// set Ctrl+Alt as HOST key not work
// this also boring me along time.
一. a workaround
but, here is a workaround, test worked:

Get key event on host ubuntu at low-level
// use tools such as showkey, evtest, or getevent

evtest, getevent (should specify input device),
// depend on /dev/input/eventX, need root
showkey not depend on input device (all keyboard are same),
// depend on /dev/console, need root
xinput test (should specify device, not same with /dev/input/eventX)
// depend on X system, not need root

detect Ctrl+Alt+Left key press
// read the key event

use xdotool set_desktop --relative -- -1 switch workspace.
// get_desktop also can check current workspace.
(I offfen put vbox in last workspace)

二. a tool demo
here is a test tool src done this:
github.com/yurenchen000/keyevent
//depend on xdotool
usage example:
sudo ./keyevent /dev/input/event3 2

detect event3 device event.
if ctrl+alt+left/right is pressed.
if curent workspace is 2 (start at 0), then do help things (for workspace switch)."