Shift key status leaking from Guest to Host
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Shift key status leaking from Guest to Host
I have a VBox session running, an app in that guest session has focus. If the shift key is pushed, an app in the host that calls the standard GetAsyncKeyState function receives notification that the shift key is down. Only tracked this down just now, so have not done a lot of testing, but looks like it is as above.
Thanks
Ken
Thanks
Ken
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: Shift key status leaking from Guest to Host
The only way for a keyboard to be truly in the guest only and not detectable by the host is to add a second keyboard that attaches via USB, then use a Virtualbox USB filter to send that keyboard as hardware into the guest.
Under all other circumstances, including normal operation, the host receives the key signals and feeds them to Virtualbox, then Virtualbox feeds the signals to the focused guest.
Under all other circumstances, including normal operation, the host receives the key signals and feeds them to Virtualbox, then Virtualbox feeds the signals to the focused guest.
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
Thanks for the reply.
I appreciate your comment about having to really have two keyboards but isn't the idea of virtual machines to have virtual hardware?
This does (and has) worked fine on VMware, just tested it again.
Appreciate your comments
Thanks
Ken
The problem here is that VBox is allowing them to also pass to app(s?) in the host.scottgus1 wrote:… the host receives the key signals and feeds them to Virtualbox, then Virtualbox feeds the signals to the focused guest.
I appreciate your comment about having to really have two keyboards but isn't the idea of virtual machines to have virtual hardware?
This does (and has) worked fine on VMware, just tested it again.
Appreciate your comments
Thanks
Ken
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: Shift key status leaking from Guest to Host
Yes. It is not typical for users of Virtualbox to have multiple keyboards, one for the host and one for each guest. Normally, only one keyboard is present.Ken S wrote:isn't the idea of virtual machines to have virtual hardware?
This is normal behavior. On the tablet I am using now, when I have the old-school on-screen keyboard up (not the new Windows 8/10 touchscreen keyboard), and I then connect my Bluetooth keyboard, the Shift, Ctrl, Alt and Caps Lock keys highlight on the on-screen keyboard when I press them on the Bluetooth keyboard. Note that this tablet does not have Virtualbox on it.Ken S wrote:If the shift key is pushed, an app in the host that calls the standard GetAsyncKeyState function receives notification that the shift key is down
I also try the same thing on my laptop, with the built-in keyboard and old on-screen keyboard. Shift, Ctrl, Alt and Caps Lock keys highlight on the on-screen keyboard when I press them on the built-in keyboard. This happens on the laptop whether Virtualbox is running or not.
It is worth noting that Windows has the ability to designate custom keyboard commands in program shortcuts. So the host Windows OS is always listening to the keyboard input stream for the modifier keys so it can respond to a custom keyboard command. Other programs could theoretically do this too.
I believe it is the host OS and not Virtualbox that is doing this, per the above. If you find that the above experiment also occurs on your PC whether Virtualbox is or is not running, then this isn't a bug.Ken S wrote:VBox is allowing them to also pass to app(s?) in the host.
If it only happens on your PC when Virtualbox is running but not when Virtualbox is completely shut down and the host has been rebooted, then a post with sufficient evidence to prove the matter to the devs should be posted on the Bugtracker.
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
Not on tables I tried herescottgus1 wrote:On the tablet I am using now, when I have the old-school on-screen keyboard up (not the new Windows 8/10 touchscreen keyboard), and I then connect my Bluetooth keyboard, the Shift, Ctrl, Alt and Caps Lock keys highlight on the on-screen keyboard when I press them on the Bluetooth keyboard.
On a laptop here, yes, if I push shift on the keyboard it highlights on the soft keyboard.I also try the same thing on my laptop
But I am not sure what the above shows … if you have a program monitoring the keyboard, it highlights what the keyboard does … maybe if there were two soft keyboards?
The same scenario works ok on VMWare, that is when a VM is running and an app in the VM has focus, the keyboard is captured, that is all keyboard actions are "captured" and only the guest app sees them.
Also works on an Apple VM (not sure what type, not my computer).
The scenario of a guest not capturing shift only happens with a VM program running, not sure trying to reproduce the problem without VBox is possible.If you find that the above experiment also occurs on your PC whether Virtualbox is or is not running, then this isn't a bug.
OkIf it only happens on your PC when Virtualbox is running but not when Virtualbox is completely shut down and the host has been rebooted, then a post with sufficient evidence to prove the matter to the devs should be posted on the Bugtracker.
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
I posted a bug report but not hopeful anything will come of it.
I have come up with a sort of workaround. The host is generally running my email program, which checks for emails periodically. Some routines work slightly differently if shift is down, e.g. check for new emails versus a complete sync. The VM generally has my developing tools, and of course shift is used a lot when editing. I am changing my programs to Ctrl and Shift combination rather than just Shift, the former would normally not be used when editing, etc.
But this has worked for years … anyhow … moving forward …
I have come up with a sort of workaround. The host is generally running my email program, which checks for emails periodically. Some routines work slightly differently if shift is down, e.g. check for new emails versus a complete sync. The VM generally has my developing tools, and of course shift is used a lot when editing. I am changing my programs to Ctrl and Shift combination rather than just Shift, the former would normally not be used when editing, etc.
But this has worked for years … anyhow … moving forward …
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
Email program now checks for both left-shift and left-control pushed together.
Ken
Ken
-
arQon
- Posts: 232
- Joined: 1. Jan 2017, 09:16
- Primary OS: MS Windows 7
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Ubuntu 16.04 x64, W7
Re: Shift key status leaking from Guest to Host
I think the only piece of truly relevant information is one you've failed to mention (other than in your vmware case, which is irrelevant) : is the keyboard actually captured by the guest, or not?
All keystrokes have to flow through the host regardless, obviously, and it's arguable just how much of a bug an async check on the state of a key (rather than a keySTROKE) really is, though I do agree with your position that it would ideally only be reflected in the guest IFF the keyboard is captured.
All keystrokes have to flow through the host regardless, obviously, and it's arguable just how much of a bug an async check on the state of a key (rather than a keySTROKE) really is, though I do agree with your position that it would ideally only be reflected in the guest IFF the keyboard is captured.
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
when I was selling software, if mine failed and someone else's worked, it at least stopped me just saying that is way it isarQon wrote:… (other than in your vmware case, which is irrelevant)
"capturing" is the jargon used by VM software, but I don't think it is real capturing, it has to go through the host is my understanding, as does disk access, etc. It is then up to the VM software to filter, direct stuff as appropriate.: is the keyboard actually captured by the guest, or not? All keystrokes have to flow through the host regardless...
I have done some internet searching and there have been quite a few reports about VBox and Ctrl, Alt and Shift not working properly, so at least it is not just me
My workaround works (to use Ctrl and shift), at least for now, can't think of anywhere else shift not working can affect.
Thanks for your help
Ken
-
arQon
- Posts: 232
- Joined: 1. Jan 2017, 09:16
- Primary OS: MS Windows 7
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Ubuntu 16.04 x64, W7
Re: Shift key status leaking from Guest to Host
Ah - perhaps that explains your inability to answer a simple question and your attempt to cover your ignorance with arrogance.Ken S wrote:when I was selling software
Just imagine: if you had put that energy into searching the manual instead, perhaps you'd have made better progress.Ken S wrote:I have done some internet searching
Still, if you're happy with your workaround, I'm happy to not waste my time trying to help you. Everybody wins.
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
Sorry, I did not realise my answers were coming across as arrogance. I am new Vbox user so I admit to ignorance. What simple question did I fail to answer and I will try to do so?arQon wrote:explains your inability to answer a simple question and your attempt to cover your ignorance with arrogance.
I have read the manual, but I admit not completely. I looked for "shift" early on. Can you point me in the direction of where in the manual I should be looking?arQon wrote:...if you had put that energy into searching the manual instead, perhaps you'd have made better progress.
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
I did try the software keyboard, described in the manual, and I guess that also counts as a workaround, but I found using it to push shift when I was typing stuff in the editor difficult. I had not found anything else in the manual that applied to my problem.arQon wrote: … put that energy into searching the manual instead, perhaps you'd have made better progress.
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
I am sorry you consider my answers as arrogant. Think I should leave this post now. Thanks everyone for your help.
-
Ken S
- Posts: 77
- Joined: 20. May 2020, 02:50
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: MS Windows 10
Re: Shift key status leaking from Guest to Host
Requested ticket to be closed.
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: Shift key status leaking from Guest to Host
Arqon, I think you came down too hard on Ken. I did not see anything arrogant in his posts or responses.
Ken, we (at least I) tend to think somewhat Virtualbox-centric here for some strange reason.
I personally am not conversant in VMware, other than the fact that it exists, so I would not know if they have programmed things to completely block all keyboard activity from the host while the guest is running.
It could have something to do with the kind of VMware being run: If it's type-1-hypervisor ESXi-style VMware, then VMware has direct control of the hardware before the OS's see the keyboard signal, and complete filtering might be possible.
Virtualbox is a type-2 hypervisor, riding on top of a host OS, so the host OS has first crack at the keyboard signal, and can filter the modifier keys as it desires. It does do so on Windows, so the custom shortcut keyboard commands can work.
This appears to be to be a side-effect of the Windows OS having the hardware under control directly, and Virtualbox does not (or cannot) prevent the host OS from seeing the modifier keys.
Setting a shortcut that looks for something as ubiquitous as the Shift key (makes capitals, rather commonly used
) might not be the best choice for a keyboard shortcut. Example: Virtualbox's Host key for keyboard shortcuts is default Right Ctrl. I use both Ctrls in my work. So I changed the Host-Key to Right-Shift-right-ctrl. Now I can work smoothly and still get keyboard control of Virtualbox.
Looks like you arrived at the same solution/workaround, to change the shortcut to a less common but still accessible combination. As I see it that's the only workaround possible.
Ken, we (at least I) tend to think somewhat Virtualbox-centric here for some strange reason.
It could have something to do with the kind of VMware being run: If it's type-1-hypervisor ESXi-style VMware, then VMware has direct control of the hardware before the OS's see the keyboard signal, and complete filtering might be possible.
Virtualbox is a type-2 hypervisor, riding on top of a host OS, so the host OS has first crack at the keyboard signal, and can filter the modifier keys as it desires. It does do so on Windows, so the custom shortcut keyboard commands can work.
This appears to be to be a side-effect of the Windows OS having the hardware under control directly, and Virtualbox does not (or cannot) prevent the host OS from seeing the modifier keys.
Setting a shortcut that looks for something as ubiquitous as the Shift key (makes capitals, rather commonly used
Looks like you arrived at the same solution/workaround, to change the shortcut to a less common but still accessible combination. As I see it that's the only workaround possible.