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

Double Shift Function often triggers unintentionally + Double Shift Action Improvement #4

Closed
MaxMoldmann opened this issue Jan 8, 2024 · 9 comments
Assignees
Labels
feature-request New feature or request plugin-bug Something about Keyshots isn't working

Comments

@MaxMoldmann
Copy link

MaxMoldmann commented Jan 8, 2024

While I find the JetBrains inspired Double Shift Function awesome it triggers unintentional many times every day.
This happens when using Shift to write an Uppercase letter (e.g. 'Shift' 'A') and then pressing Shift down again for any reason.

The resulting sequence like this: 'Shift-Down' 'A-Down' 'A-Up' 'Shift-Up' 'Shift-Down' should not trigger the Double Shift function, but it does.

Likely Root Cause:
The Keyshots plugin seems to count a Shift press even when there was another key pressed while Shift was pressed down.
Then a following Shift Down event triggers the function, although it should only trigger when there was no other Key event between a sequence of Shift Key down, Shift Key up, Shift Key down, Shift Key up events.
In other words Shift Key up should only count as one time pressed when there was only Shift Key down events since and no other key event.

Possible Workarounds:

  1. Remember last key event. Look for Shift-Down event. If last key event was not also Shift-Down increase shift counter variable. Any other key event resets the shift counter variable to zero. Look for Shift-Up event. Increase Shift counter variable. If Shift counter variable hits 3 or 4 we know it is a real double shift and Shift Down and Shift Up came twice.

  2. Does not fix Root cause, but might be simple and effective: Option to relax sensitivity. Internally this will look for Triple instead of Double Shifts

  3. Does not fix Root cause: Add a short filter time that will ignore a double Shift event from counting when Shift Key Up and Shift Key Down happen too fast in sequence

Resource:
Javascript in Browser Keyboards Event Playground: https://www.w3docs.com/tools/editor/20348

@KrazyManJ
Copy link
Owner

Hello @MaxMoldmann , thank you for posting this issue. Also I apologize for late response due to finishing my semester at University.

I've looked at your problem. To be honest I did not look for your possible workarounds, usually I want to solve it myself, but I appreciate your attempt to help me.

My workaround:

Added variable to remember last pressed (not released) key, and check if this key is equal to released key. If not, then it's obvious that this double-key command was interrupted via other key (in your case with key) and won't register it as first-hit of double-key command key.

It also helped me to fix one problem with releasing double-key command, when it registers release of it as first hit of this command (happens with double Ctrl adding caret cursors command).

After few minutes I'll push and release fix version, where this mistake will be fixed.

Thank you again for your issue post and hope that Keyshots is your #1 shortcuts plugin. Have a nice day!

@KrazyManJ
Copy link
Owner

Currently published fixed version here, and in Obsidian as well:

https://github.com/KrazyManJ/obsidian-keyshots/releases/tag/2.1.1

@KrazyManJ KrazyManJ self-assigned this Jan 21, 2024
@MaxMoldmann
Copy link
Author

Thank you for the quick response! I appreciate it especially as being a Software Engineer myself. I feel like the quick search is now being activated unintentionally less often. However the issue is tricky and not fully fixed. You can reproduce the problem easily by writing something like "AB&C" in a note. If you write "AB" while holding shift then quickly holding Shift down in order to get to the "&" sign will activate Quick Search even before pressing the "&" key, while it should only do so with an intentional Double Shift while no other key is being pressed.
I just edited and fixed my comment above about the potential workaround No.1 as it might still be valuable.

@KrazyManJ
Copy link
Owner

Hello once and again,

well, I've checked my code again and I am actually surprised that in your case these unintentional activations happened less often than before because I've forgotten one keyword in code to make my previous fix fully work. Due to that my code registered, that the keychain was interrupted, but was not cancelled and still registered as success key press.

Now I am trying to make quick switch pop happen for like 5 minutes without any success and now, I can say, it seems to be fixed.

I apologize for non-fixing my code properly, now I have a lot of stuff to do with Keyshots, so after refactoring few files, I'll again release fix for that and let you know here when it releases. Please stay patient.

Also I'll leave this issue open until you'll let me know that it've been definitely fixed.

@KrazyManJ KrazyManJ reopened this Jan 25, 2024
@KrazyManJ
Copy link
Owner

Currently I've released fix release for this problem here:

https://github.com/KrazyManJ/obsidian-keyshots/releases/tag/2.1.2

@MaxMoldmann
Copy link
Author

Thank you for your super fast response!
I can confirm it works for me!

Just on a side note: JetBrain IDE's trigger after the second shift-up (if within a certain time limit). Keyshots triggers earlier after the second Shift Key-down. I would suggest changing it to match what JetBrains does as the User still might want to write an Uppercase letter after pressing Shift and releasing Shift just before. So only after the second uninterrupted Shift Key-up you can be totally sure that the File open dialog was really intended by the user.

@KrazyManJ KrazyManJ added plugin-bug Something about Keyshots isn't working feature-request New feature or request labels Jan 26, 2024
@KrazyManJ KrazyManJ changed the title [DEFECT] Double Shift Function often triggers unintentionally Double Shift Function often triggers unintentionally + Double Shift Action Improvement Jan 26, 2024
@KrazyManJ
Copy link
Owner

@MaxMoldmann, this sounds like a pretty good improvement to actually make it work fully the same way as in JetBrains.

  • Currently I've coded the feature of command execution on second release rather than on second press, and I am planning to release version 2.2.0 that will improve this.
  • Next thing I've improved is to detect time between press and release, for example if I hold second shift for too long, Quick-Switch window won't pop up.
  • Also I've added command Open Command-Palette Window by pressing Ctrl twice without interrupting.

Right now I am finishing other project, but stay focused, this improve will be released soon!

@KrazyManJ
Copy link
Owner

Hello @MaxMoldmann currently I've been working on additional Keyshots features and now, I've released version which fixes and improves all of what I've said above:

  • Currently I've coded the feature of command execution on second release rather than on second press, and I am planning to release version 2.2.0 that will improve this.
  • Next thing I've improved is to detect time between press and release, for example if I hold second shift for too long, Quick-Switch window won't pop up.
  • Also I've added command Open Command-Palette Window by pressing Ctrl twice without interrupting.

Release 2.2.0 is now available here:

https://github.com/KrazyManJ/obsidian-keyshots/releases/tag/2.2.0

@MaxMoldmann
Copy link
Author

This is awesome! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request plugin-bug Something about Keyshots isn't working
Projects
None yet
Development

No branches or pull requests

2 participants