Virtualbox is nice because it comes with a set of drivers called guest additions, that allow you to be able to resize the guest window and provide seamless integration for the mouse and keyboard, without the need for using the host key. Installing guest additions also allows for more advanced networking modes, among other things. This tutorial assumes that your guest OS is CentOS or other Red Hat based, although the installation is similar for all distributions, you just have to substitute your distros package manager for yum.
To get started we need to install a few packages as root. Type the following into a terminal:
sudo yum install gcc kernel kernel-devel
Yum should ask you if you really want to install the packages, so tell it yes. After the packages have installed, reboot the virtual machine, and login to the desktop. Then, from the Virtualbox menu, select "Devices > Install Guest Additions."
This should automount the guest additions, which will show up as a CD on the desktop. Open another terminal, and switch to the root user:
Enter your password and change to the directory where the guest additions reside:
You might have a different version of guest additions, so substitute accordingly.
Next, depending on your guest machine's architecture, run either VBoxLinuxAdditions-x86.run or VBoxLinuxAdditions-amd64.run using sh.
This will take a couple of minutes, just be patient. The system is recompiling the kernel with the new guest addition drivers. After it finishes, reboot. After your machine finishes booting, if everything went well you should be able to resize the window and the mouse will move seamlessly from guest to host without the need for using the host key.