Feedback about this page and suggestions for improvements are always welcome on the vbox-dev mailing list<1>!
Investigating problems with keyboard input in VirtualBox
This page is intended to help people with programming skills who want to investigate problems with keyboard input in VirtualBox.
The code which picks up keyboard events from the host for the default user interface it in the files:
src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
Unfortunately there is no logging available here. The code to read the keyboard is different for Windows, X11 and OS X.
After this, the events are passed on to Main, which is the middle-layer between front-ends and virtual machines.
src/VBox/Main/src-client/KeyboardImpl.cpp
Main takes care of things which otherwise all front-ends would have to do (not much for the keyboard), then passes the events on to the device emulation code. The path here will be different depending on whether we are using PS/2 keyboard emulation (almost always) or USB keyboard. The device emulation makes the events appear on the guest virtual hardware.
src/VBox/Devices/Input/
There is logging<2> code here, respectively log group "dev_kbd" and "usb_kbd"
To monitor exactly what the guest is seeing you are best using native tools in the guest operating system, such as evtest, xinput and xev in Linux/X11 guests and keylook<3> in Windows guests.