MacOS – Arrow keys output numbers when connecting to Ubuntu VirtualBox guest on Windows 7 host via remote desktop connection

keyboardmacosremote desktopunixvirtualbox

I have a Ubuntu guest running on my Windows 7 host. I then wanted to connect remotely from my Macbook Air in bed, and so accessed the VM via Microsoft's OSX remote desktop client. I'm able to successfully connect to the Ubuntu guest VM, however my Macbook Air's arrow keys output numbers when pressed making it impossible to navigate with them (a big problem for coding).

Additionally, the touchpad is hyper-sensitive when using two fingers to scroll on the page.

I found a random forum post suggesting to turn off Numlock on the Windows host machine which I did, however nothing changed (even after rebooting the VM and reconnecting).

How can I fix the arrow keys so they function as arrow keys?

Best Answer

The problem is that the NumLock state gets stuck to On inside the RDP client. Tools like numlockx don't help - the client returns the state back to On. It's not just the allow keys that stop working - Ins, Del, Home, End, PgUp and PgDown are affected as well. The solution I found is to remove all references to keypad keys affected by NumLock from the xmodmap settings. To do that, run on the guest

xmodmap -pke | sed 's/KP_\([^ ]*\) KP_.*/\1/' > $HOME/.xmodmap

.xmodmap will be loaded on the next login. To load it immediately, run

xmodmap $HOME/.xmodmap

Alternatively, use the newer version of the RDP client (Microsoft Remote Desktop 10). It fixes the arrows. It's a full rewrite of Microsoft Remote Desktop, it has its own issues with the Insert key and middle mouse button.