Potential fix for CMD key woes in macOS #159
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR (see below under "Details" if interested)
Forces a "key-up" event to be generated when combining CMD key with some other key. For example, the following sequence will result in the "R" key being held down on the remote side...
-Press down CMD
-Press down R
-Release R
The "R" will not register as being released until the "CMD" key is released. This is sub-optimal with most things (especially things like FN-CMD-TAB, etc.).
Details
In macOS using Chrome or Safari, when sending a key sequence that includes the CMD (Meta) key, the browser will never actually observe a "Key Up" for the key event. This results in "stuck" keys when performing actions like FN-CMD-TAB, CMD-S, etc. For scenarios where you have a macOS machine on both the client and host, it is common to use FN-CMD-TAB to tab between windows on the host machine. The current version of kvmd will behave as though you never release "TAB" until you also release the "CMD" key.
This behavior can be observed on macOS (in Chrome and Safari) using the following test page...
https://w3c.github.io/uievents/tools/key-event-viewer.html
The proposed solution here does the following...
The only downside I see thus far here is it prevents you from being able to actually hold down a key when the Meta key is also depressed. There are likely very few scenarios, if any, where a user would actually WANT to do this. But perhaps instead of this code ALWAYS being enabled, we offer a setting in Keyboard settings like "Enable CMD Key Fix" or however kvmd maintainers would like it to be named.
So far this fix is working well locally for me, and really eliminates a major headache. I'm happy to make adjustments to this as maintainers see fit, in order to get this into the base repo. Thanks.