Page 1 of 1

Non-toggle based host keys?

Posted: 14. Jun 2020, 10:17
by yoloClin
Is it possible to have non-toggle based keyboard capture and release keys?

For example: bind right-control release input (and if input is already released, do nothing), and left control to capture keyboard input (and if it's already captured, either do nothing or send the event to the guest).

Re: Non-toggle based host keys?

Posted: 14. Jun 2020, 15:16
by scottgus1
Normal operation for keyboard capture is:
Keyboard is auto-captured when the guest Virtualbox window receives focus (becomes the active window). If Keyboard Integration is enabled (often requires Guest Additions) keyboard is auto-released when the guest Virtualbox window loses focus. If Keyboard Integration is disabled, the Virtualbox Host key must be pressed to release the keyboard from the guest.

It sounds like you want to replace "auto-capture when the guest Virtualbox window receives focus" with 'hit left control so the keyboard goes into the guest', or add it in addition to the present 'guest receives window focus' function.

If this summary is accurate, then Virtualbox has no such function. Virtualbox puts the keyboard into whichever guest window has focus. Getting the correct guest window to have focus is the operation you will need to tie 'hit left control' to. Controlling which window on the computer has focus is a function of the host OS, not Virtualbox. 3rd-party software will be required for this.

Re: Non-toggle based host keys?

Posted: 15. Jun 2020, 01:25
by yoloClin
It sounds like you want to replace "auto-capture when the guest Virtualbox window receives focus" with 'hit left control so the keyboard goes into the guest', or add it in addition to the present 'guest receives window focus' function.
Not so much that. Still auto-capture when the guest VirtualBox window recieves focus, but with a button which explicitly exits keyboard focus rather than the current 'toggle' behavior of the VirtualBox key (by default, right CTRL).

Re: Non-toggle based host keys?

Posted: 15. Jun 2020, 21:48
by scottgus1
The host key appears to 'toggle' the arrow in the status bar on/off.

Without Guest Additions installed, keyboard might or might not be blocked from the guest window by the state of the 'toggled' arrow. One guest I tested did not get keyboard keys when the arrow was off, then I started another guest and found the first guest did not get blocked anymore.

With GAs installed and keyboard/mouse integration active, the Host key "toggle" does not stop the keyboard from going into the guest as long as the guest window has focus.

I don't believe there is any function in Virtualbox to change these behaviors.

What is the problem this 'toggle' causes for you?

Re: Non-toggle based host keys?

Posted: 17. Jun 2020, 01:07
by yoloClin
What is the problem this 'toggle' causes for you?
Basic usability - aside from the 'toggled' arrow icon, there's no way of knowing whether alt+tab is going to be interpreted by my host or the guest - window decorations do have some indication of whether or not the VM is the active window, but they don't differentiate whether keyboard is currently being captured or not. Hitting right ctrl toggles the capture state, but the try->fail->right ctrl->try again workflow isn't very nice (particularly as in the case of Alt+Tab, it typically changes WM state of either the host or guest in an unwanted way).

Re: Non-toggle based host keys?

Posted: 17. Jun 2020, 18:35
by scottgus1
OK, I think I understand you.

If I Alt-Tab while a guest has focus, the Alt-Tab goes into the guest. After using the Host Key, Alt-Tab goes to the host PC. Using Alt-Tab on the host to highlight the guest, then keyboard goes back into the guest.
yoloClin wrote:window decorations ... don't differentiate whether keyboard is currently being captured or not.
The "down arrow" at the far right end of the guest Virtualbox window's status bar turns green when the guest has focus/keyboard, and goes black when the guest does not have focus/keyboard. (For example, I have three guests open now: an XP with Guest Additions, an XP without GAs, and a DOS. All three guest down arrows are black while I type here. Soon as I Alt-Tab or mouse-click into one of those guests, that guest's arrow will turn green.) This is an indication of which guest or the host will receive the keyboard input. This indicator is present whether Guest Additions are installed or not. It is small but it is there.
yoloClin wrote:Hitting right ctrl toggles the capture state
Host key only toggles the down arrow "light" if you hit it but do not change focus to another window. Keyboard capture remains in the guest and the guest OS continues to receive the typing even if the down arrow light is off, as long as you don't change focus to another window.

Though the Host key only toggles the light but keeps the keyboard in the guest until focus moves away from the guest window, the Host key also releases the mouse from a guest that is using a PS/2 mouse and does not have Guest Additions installed.

Once you change focus to another window, Host key does not put you back in the guest. You would need to use Alt Tab for that. If you want a keyboard shortcut to put the focus back on the guest window so you don't have to type Alt-Tab, you will need 3rd-party software. Virtualbox does not have a shortcut for that function.

I just noticed this is the Linux Hosts forum. I am on a Windows host, but I doubt anything is different for Virtualbox operation on Linux Hosts.