JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.91k stars 1.16k forks source link

Support for Global Hotkey detection #389

Open SebastianAigner opened 3 years ago

SebastianAigner commented 3 years ago

(This might be out of scope for CFD, so feel free to ignore).

Electron has the possibility of detecting Global Shortcuts:

Detect keyboard events when the application does not have keyboard focus. The globalShortcut module can register/unregister a global keyboard shortcut with the operating system so that you can customize the operations for various shortcuts.

It would be nice to have the same functionality available for compose for desktop applications – similar to tray integration, global shortcuts make helper tools easier to reach and use. However, it seems usage of system-wide hotkeys is nontrivial on the JVM, and library support (like JHotKeys) is meager.

olonho commented 3 years ago

Overall, look sensible that API like that may be helpful. But it probably requires some native code (in Skiko?).

jimgoog commented 3 years ago

Intuitively, it seems like this is orthogonal to Compose? Feels like JHotKeys (or a KotlinNative variant thereof) might be the right project for something like this? Anyone interested in that feature should contribute to JHotKeys to make it less meager or start their own KotlinNative-based competitor?

Is there a reason this needs to be Compose specific? Based on the description, if the window doesn't have focus, then it doesn't seem like it would need to tie into the Compose focus manager or anything like that?

jimgoog commented 3 years ago

I suppose the argument that it is similar to tray integration is the most compelling one, although I wonder if maybe tray integration should also be spun off into its own separate library/dependency. The thing about tray integration is that you probably want the tray to have a menu and that menu would presumably be rendered with Compose, so the relationship/dependencies are a bit more entangled there.

Probably documenting how to use JHotKeys (or whatever solution) in a tutorial might be a good idea though, especially to parallel the electron documentation there.

Animeshz commented 3 years ago

A bit of off-topic, I did asked it in the slack as well, I didn't got any option available at that time so started a small project on my own. I'd love if it can be integrated with the compose itself, the base native code for linux & windows can be found here if anybody want to look at it as a reference :-)

EinHecki commented 2 years ago

Is there anything new to this?

jonasborggren commented 1 year ago

Any updates on this?

dima-avdeev-jb commented 1 year ago

Any updates on this?

No updates for now

FedrBodr commented 1 year ago

@SebastianAigner so at the end did you find a solution to global hotkey with compose desktop?

holtenko commented 1 year ago

I'm using jkeymaster, it's worked for my case. here is the Github repo: https://github.com/tulskiy/jkeymaster

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.