noVNC icon indicating copy to clipboard operation
noVNC copied to clipboard

The System steals keyboard events for certain system keyboard shortcuts, e.g. Cmd+Shift+4

Open namper opened this issue 1 year ago • 10 comments

Describe the bug The system steals keyboard events for certain system keyboard shortcuts, e.g. Cmd+Shift+4. Unfortunately, this isn't considered a focus loss, so the server doesn't realize it has lost a few keyboard events and can end up in a confused state.

To Reproduce Steps to reproduce the behavior: Press CMD+SHIFT+4 Take screenshot Click on server and see that server is confused as you can't click but can only drag.

Expected behavior noVNC should catch focus loss and reset keyboard state.

Screenshots cced1247-88f4-4ddf-945b-1c314fb2ba51

Client (please complete the following information):

  • OS: macOS
  • Browser: Chrome
  • Browser version: 115.0.5790.170

Server (please complete the following information):

  • noVNC version: 1.4.0
  • VNC server: TigerVNC
  • WebSocket proxy: websockify

Additional context Here is this exact problem solved by tigervnc https://github.com/TigerVNC/tigervnc/commit/4f6d4895c3420e5ac301a916bced4a0065a19183

namper avatar Aug 17 '23 18:08 namper

Unfortunately, we don't have access to the low-level events like TigerVNC has, so we can't apply the same workaround.

Likely this needs to be fixed in the browsers so that they send keyup events when this happens.

Have you reported the issue to the different browsers?

CendioOssman avatar Aug 21 '23 14:08 CendioOssman

Thanks for reply. I am aware we can't access the low level API hack that TigerVNC is doing. Unfortunately, this bug is also reproducible on Safari & Mozilla. What would you advise as potential interim solution, for example detecting that Command and Shift is pressed and scheduling Command & Shift key down events to server.

Versions: Safari: 16.5 Firefox: 107.0.1

namper avatar Aug 21 '23 15:08 namper

I found similar issues attempted fix by KasmVNC's fork of noVNC will test this solution. https://github.com/kasmtech/noVNC/commit/2b7e3321ae81cff99510738c2ecee1bcd2853d9b

namper avatar Aug 21 '23 16:08 namper

Trying to perfectly detect every possible troublesome shortcut would be a maintenance nightmare. So what Kasm has done is probably a more feasible mitigation of the issue.

It's important that the issue get reported to all the browsers, though, so a proper solution can be available long term.

CendioOssman avatar Aug 22 '23 13:08 CendioOssman

Raised bug to chromium https://bugs.chromium.org/p/chromium/issues/detail?id=1474894#c3

namper avatar Aug 23 '23 18:08 namper

Many thanks. I don't suppose you could also inform Firefox and Safari (WebKit) of this issue?

CendioOssman avatar Aug 29 '23 14:08 CendioOssman

Many thanks. I don't suppose you could also inform Firefox and Safari (WebKit) of this issue?

Likewise. Raised to all 3 of them.

WebKit: https://bugs.webkit.org/show_bug.cgi?id=260866 Mozila: https://bugzilla.mozilla.org/show_bug.cgi?id=1850583 Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1474894#c3

namper avatar Aug 29 '23 17:08 namper

Weird. I tried it on Brave (a sanitized Chrome clone, Cr 125) on macOS 14.5 Sonoma and connected to two VNC servers one with noVNC 1.3.0 and the other with 1.5.0, but the screenshot shortcut cmd+shift+4 did work normally and was not swallowed by the browser or noVNC. These servers run TigerVNC. The same applies to Safari.

freebrowser1 avatar Jun 30 '24 08:06 freebrowser1

Weird.

I tried it on Brave (a sanitized Chrome clone, Cr 125) on macOS 14.5 Sonoma and connected to two VNC servers one with noVNC 1.3.0 and the other with 1.5.0, but the screenshot shortcut cmd+shift+4 did work normally and was not swallowed by the browser or noVNC. These servers run TigerVNC.

The same applies to Safari.

Screenshot will work fine but keyup event will be swallowed. What was version of Chrome and Safari that you tried with ?

namper avatar Jun 30 '24 10:06 namper

Screenshot will work fine but keyup event will be swallowed. What was version of Chrome and Safari that you tried with ? Chrome (Brave) v.125 and Safari 14 (?) the one supplied with macOS 14.5.

freebrowser1 avatar Jul 01 '24 16:07 freebrowser1