Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curious about why the KeyboardShortcut is caught within a VNC session on the remote computer rather than on the local one #197

Open
godbout opened this issue Jan 3, 2025 · 2 comments

Comments

@godbout
Copy link

godbout commented Jan 3, 2025

trying to wrap my head around this. just out of curiosity. i have an app that uses the KeyboardShortcuts package. my app is both on my local and my remote computer. if i'm on Screen Sharing, pressing my KeyboardShortcut will activate my app within the Screen Sharing environment, on the remote computer, rather than on a local one. no right or wrong here, but curious about why is this happening. is this done on purpose? KeyboardShortcuts isn't using an event tap, so there's not that concept of where in the event stream the tap is placed, which could explain the behavior depending on where the tap is. i don't have much knowledge about the Carbon API etc. so there's definitely something basic i'm missing. curious curious curious...

@sindresorhus
Copy link
Owner

Keys are generally captured when in VNC.

@godbout
Copy link
Author

godbout commented Jan 4, 2025

Keys are generally captured when in VNC.

good one hahahhaahhahahahahahah alright i deserve it hahahahhahahhhahahhahhaha

ok, so lemme try to give a bit more details:

  1. i build three apps: kindaVim, Wooshy and Scrolla (naming them so it's easier to remember, and also for self-promotion of course)
  2. Wooshy and Scrolla are using your masterpiece KeyboardShortcuts package. kindaVim doesn't and uses an event tap instead because it needs to grab every single key in order to generate Vim motions as a result
  3. when on Screen Sharing, hitting the keyboard shortcuts for Wooshy and Scrolla makes Wooshy and Scrolla open on the remote computer. when hitting my own keyboard shortcut system for kindaVim (like escape, or a sequence of keys) kindaVim reacts on the local computer

so what's happening here is that kindaVim's event tap grab the keystrokes before Screen Sharing does. for Wooshy and Scrolla, Screen Sharing grabs the keystrokes before they (hence before KeyboardShortcuts) do. obviously, there is a priority in which system (event tap, KS hotkeys)/apps grab the keystrokes first.

now why i'm asking you/here is because:

  1. i'm dealing with an issue with iTerm. when i use iTerm's hotkey iTerm opens on the local computer instead of the remote one. i'm dealing with iTerm's developer George, who says the hotkeys are handled through Carbon keys blah blah blah, the same way KeyboardShortcuts does. i haven't dig/dug yet into iTerm's source, but George being the maintainer of iTerm for the past like, 15 years?, i kinda believe he knows what he's saying
  2. as we all know you are a Wizard. so i thought that maybe you DO have some knowledge about how keystrokes grabbing priorities work when dealing with the old Carbon keys APIs. i thought that maybe you'd have something like "yeah KeyboardShortcuts grabs keys very late in the old Carbon keys APIs event process so other apps like Screen Sharing will catch them first and here's a link to the source where the grabbing keys priority is defined: github.com/blahblahblah"

hope that makes sense! i'm just a big fan of knowledge i can't help it hope i'm not abusing your time xoxo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants