Getting AltGr to run on Ubuntu under VirtualBox on Windows

I need to dump this arcane piece of knowledge somewhere so it will get indexed by Google and maybe make things easier to find for the next person who has this problem. So you installed a Linux in a VirtualBox under Windows machine, and now your Right Alt (aka. AltGr) started to work like CTRL under Linux? Here's a quick solution that makes no sense whatsoever, but works. Go to the VirtualBox Manager window, open File->Preferences, and under Input tab uncheck the Auto Capture Keyboard option. Ta da, your AltGr should be working properly now. As a side effect, your Alt+Tab combo will stop working, being captured by Windows now. Also, make sure that when a VirtualBox pop-up shows up, asking you to capture keyboard, you click Cancel - otherwise AltGr will get back to being broken again until you "uncapture" input, by e.g. switching to host Windows system. Source: about an hour or two in total wasted on three different occasions to find this SuperUser answer. Now that it's fixed, I can finally get back to playing with StumpWM.