A few days ago on my German keyboard the Alt Gr key didn’t work anymore. When I tried to enter special characters such as ~, @ and | I used the typical German key combinations [Alt Gr] + [+], [Alt Gr] + [q] and [Alt Gr] + [<]. I was supprised that Windows 7 returned me +, q and < as I did not pressed Alt Gr at all. I was shocked because how should I live with a system that cannot provide @ for email addresses or | for piping in SSH sessions to Unix and Linux any more?
I was searching the Internet for possible solutions. There were many people with German, Swiss and French keyboards who encountered the same problem. There were several discussions but none provided a solution to my problem. Alt Gr still remained to be dead on my keyboard.
After a while of testing. The good old solution on a Windows system seemed to solve my problem: Reboot. When my PC came up again my beloved Alt Gr worked again and provided the essential characters ~, @ and |. I was angry about Windows but happy that everything worked again.
Yesterday the problem suddenly occured again. What did I change? What was the event that trigged that malfunction?
I quitted application by application and — surprise (!!) — after quitting VirtualBox my Alt Gr key worked again! I appologize to Windows 7. It didn’t cause the problem. I started playing with my VirtualBox and finally figured out when the Alt Gr key stopped working.
Reason and Solution
With installed Virtual Box Guest Additions your virtual machine will loose capture of your mouse pointer if you move the mouse out of your VirtualBox. You won’t need to press the host key to return to your host operting system (Windows 7). A very comfortable feature.
I figured out that this comfort is the reason for my problem. Whenever VirtualBox captured mouse and keyboard the Alt Gr key of Windows 7 did not work any more. If I released mouse and keyboard explicitly by pressing VirtualBox’s hostkey the Alt Gr key of Windows 7 worked as expected. So it is not only enough to move the mouse pointer out of the virtual machine but to release the capture explicitly by pressing the hostkey.
[Update 2013/04/26] This problem shall be fixed in future 4.2.x and later releases of VirtualBox. The current release 4.2.12 is still affected by this bug. The next one shouldn’t be any more. See VirtualBox bug #2613. Thanks to Michael Thayer (Oracle) for this information.
[Update 2014/04/16] Situation has become much more better since release of 4.2.12. Unfortunately the problem is not fixed at all. From time to time I encounter this problem with Alt Gr key again. Currently I use VirtualBox 4.3.10. Meanwhile the bug #2613 was reopened.