MrKai77/Loop

๐Ÿž Pressing one of two required key to activate Loop wrongly activate Loop if pressed just after switching space.

Opened this issue ยท 2 comments

Write commented

Bug Description

Sorry for horrible title.

I have my loop mapped to ctrl(^) & cmd. Switching to space 1, is mapped to ^1, and so on for 2nd and 3rd space.
Pressing and releasing instantly ^2 to switch to space 2, THEN pressing cmd to do something wrongly activate Loop.
This doesn't occure when NOT switching space : for example, pressing ctrl, releasing it then pressing cmd DOESN'T activate loop, unless you just switched space.

Bug occurs with both 0.0 and 0.1 delay, I haven't tried more delay.

Steps To Reproduce

  1. Bind ^1 to Space 1 and ^2 to Space 2
  2. Bind loop to ^ and cmd
  3. Switch from Space 1 to Space 2 with ^2
  4. press cmd immediately after space is switched and move the mouse around, Loop will activate as if ctrl was still pressed.

Expected Behavior

  1. Bind ^1 to Space 1 and ^2 to Space 2
  2. Bind loop to ^ and cmd
  3. Switch from Space 1 to Space 2 with ^2
  4. press cmd wouldn't activate Loop since ctrl is released.

Actual Behavior

As stated in Step To Reproduce.

Screenshots

No response

macOS Version

15.1

Loop Version

Version ๐Ÿงช 1.2.0 (1380)

Additional Context

No response

Final Checks

  • My issue is written in English
  • My issue title is descriptive
  • This is a single bug (multiple bugs should be reported individually)
  • I can help with fixing or developing this issue (tick if you can help).

Very interesting! I suspect that this has a common cause with #372.

I found out that this is happening as during a space switch, macOS takes full control of keypress events, effectively blocking Loop from being able to detect the trigger key during that specific period of time.

This will get a little technical but, I found a way around this, which was to use a CGEvent key event handler instead of the current NSEvent handler. A CGEvent handler captures key events at the system-level, while a NSEvent handler captures them at an app-level. It worked, but also caused many unwanted side-effects. With that said, I am quite sure that this is possible to solve with a little more tinkering, so thanks for reporting!

Write commented

If there's anything I can do (using a test build for some time, etc.) you can reach to me anytime.

Cheers, and thanks for your hard work.