Is this on a laptop internal keyboard or an external USB or BlueTooth keyboard? An external USB keyboard should not have this problem.
I may be mistaken though, I have not used VirtualBox in a while, preferring VMWare products instead. As I recall you can, and this can be dangerous, use the USB passthrough function on VirtualBox to avoid macOS keymapping and/or VirtualBox keypress filtering.
The danger with this is that you can have the virtual machine grab your keyboard and it will be difficult to get it back to the host macOS system. I would not recommend trying this on the only keyboard connected. Use a second keyboard. Maybe even have a third just in case. If something goes wrong plug in another keyboard and use that to get control back.
If you have a USB keyboard you can try on this then just try plugging it in to see if that works, then go to the dangerous step of USB passthrough. I don't want to over sell it here, it's not terribly difficult to recover, but I don't want to under sell either. VMWare products prohibit the passthrough of HID devices for this reason, which can be frustrating some times.
Another option is to try some kind of remote control software. There's Microsoft's Remote Desktop. There's various versions of VNC. Plenty of others, most of which I recall as being a derivative of those two.