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

Detecting repeat key presses when the user is holding down a key? #59

Open
fgimian opened this issue Feb 9, 2024 · 4 comments
Open

Comments

@fgimian
Copy link

fgimian commented Feb 9, 2024

Hey folks, hope you're doing well.

At present, if a user holds down a global hotkey, this library emits a single event with state Pressed, and when the user releases the key, a single event with 'Released' is emitted. Tested on Windows 11 Pro.

However, in many cases, users may hold down a hotkey and expect it to continue firing at the rate set by the OS. Would it be possible to at least have a way to enable this behaviour please?

Thanks heaps
Fotis

@amrbashir
Copy link
Member

It should be possible on Linux and Windows but idk about macOS, there is a lack of documentation around the APIs, the only thing I could find is https://github.com/planetbeing/xpwn/blob/ac362d4ffe4d0489a26144a1483ebf3b431da899/idevice/QuicktimeSDK/CIncludes/CarbonEvents.h#L943-L951 and it doesn't seem possible.

What is your use-case for repeated events? I believe you can simulate the repeated keys by looping until a released event.

@fgimian
Copy link
Author

fgimian commented Feb 18, 2024

It should be possible on Linux and Windows but idk about macOS, there is a lack of documentation around the APIs, the only thing I could find is https://github.com/planetbeing/xpwn/blob/ac362d4ffe4d0489a26144a1483ebf3b431da899/idevice/QuicktimeSDK/CIncludes/CarbonEvents.h#L943-L951 and it doesn't seem possible.

What is your use-case for repeated events? I believe you can simulate the repeated keys by looping until a released event.

Apologies for the late reply and thanks for your help. This does seem to work quite easily on Windows as you mention but indeed I have never tried such a thing on macOS.

In my case, I am registering a global hotkey for controlling the volume of an audio interface using the volume up/down keys. As you can imagine, much like Windows' native volume control, it is very common to hold volume up or down to reach the desired volume.

Presently I'm using the native Windows API calls myself but would love to use your cross-platform implementation.

@amrbashir
Copy link
Member

amrbashir commented Feb 23, 2024

We can add repeating behind a feature flag or an option on the GlobalShortcutManager but would only work on Windows and Linux. We can maybe emulate the repeating behavior on macOS but what should be the frequency?

@fgimian
Copy link
Author

fgimian commented Feb 23, 2024

We can add repeating behind a feature flag or an option on the GlobalShortcutManager but would only work on Windows and macOS. We can maybe emulate the repeating behavior on macOS but what should be the frequency?

On Windows, this can be configured via the OS itself:

image

So I think it optimally would be configurable for OSs that don't support it natively.

What do you think?

Cheers
Fotis

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