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
New Feature to map Ctrl to Esc on Release #113
Conversation
Track caps-lock state separately from alphaShift.
Didn't realize "none" was acting a bit different when I tested last. It was treating caps-lock as both ctrl and the normal caps-lock. That is, you could press caps-lock & h at the same time to delete a letter and press caps-lock. Should be working now.
Adds option to make ctrl act as esc if released without pressing any other keys. (If other keys are pressed, it'll continue to function as a regular ctrl modifier.) This supports mapping caps-lock to ctrl (either via iVim or system settings). So if this new setting is turned on, both caps-lock can also function as both ctrl and esc. note: only tested on iPad and in combination with system-settings and iVim's caps-lock settings. Tests: Editted text while randomly pressing and holding physical caps-lock or ctrl keys. - When neither iVim nor System is changing Caps-Lock or Ctrl behavior - When iVim's Caps-Lock is mapped to Ctrl - When iVim's Caps-Lock is mapped to Esc - When System's Caps-Lock is mapped to Ctrl - When iVim's Caps-Lock is mapped to Ctrl and Ctrl-to-Esc-on-release is turned on - When System's Caps-Lock is mapped to Ctrl and iVim's Ctrl-to-Esc-on-release setting is turned on - When both iVim and System are mapping Caps-Lock to Ctrl and iVim's Ctrl-to-Esc-on-release setting is turned on
The reason I said "we can even escape from the dependency on iOS 13.4" was that I thought the parts like What is the purpose of these |
They're used to inject a virtual `esc` press when `ctrl` is released, so it needs to know when the `ctrl` key press has ended. I haven't looked deeply into it, but can't seem to find a way to track key-up/released events before iOS 13.4 (i.e. without looking at the pressed `key` ).
…> On May 11, 2020, at 9:03 PM, Terry Chou ***@***.***> wrote:
The reason I said "we can even escape from the dependency on iOS 13.4" was that I thought the parts like presses.first?.key.map(keyPressed) were not necessary. Because the pressesXXX methods were introduced into iOS since version 9.0 and only the UIKey type requires 13.4.
What is the purpose of these pressesXXX override there? If we don't need to fix the "failure of mapping caps lock to ctrl in iOS 13", can we get rid of them completely?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I believe that if we register to capture only the |
The press event in keyCommandTriggered occurs on key-down not key-up. So it'll be called before `ctrl` is released, so we won't be able to inject `esc` there.
… On May 11, 2020, at 9:31 PM, Terry Chou ***@***.***> wrote:
I believe that if we register to capture only the ctrl (as the line VimViewController.keyCommand(input: "", modifierFlags: .control) does), we can get the event "ctrl key was pressed without any other key" right in method keyCommandTriggered. Can we do the esc injection there without the help from pressesXXX methods?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I see. How about we record that "only |
That might be fine, it seems like there's a risk to encountering race conditions between calling pressesXXX and keyCommandTriggered.
Though, you'd still have the bug around mapping `caps-lock` to `ctrl`. And that fix still needs iOS 13.4.
… On May 11, 2020, at 9:42 PM, Terry Chou ***@***.***> wrote:
I see. How about we record that "only ctrl pressed" in keyCommandTriggered then we only need to decide to do the injection according to whether this record exists or not in pressesXXX methods? In this case, maybe parts like presses.first?.key.map(keyPressed) are not really necessary.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Let's get rid of the "fix of mapping Also, I see you have changed the development version to 13.4. Can you please change it back to 10.0, so that I could do the merge. |
Yeah, I'll revert the version change when I make the changes you mentioned.
… On May 11, 2020, at 10:18 PM, Terry Chou ***@***.***> wrote:
Let's get rid of the "fix of mapping caps lock to ctrl in iOS 13.4", because users would choose the system's native mapping over this, and our code would be lighter.
Also, I see you have changed the development version to 13.4. Can you please change it back to 10.0, so that I could do the merge.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Added work around for iOS 10.0. Though, I haven't tested it on any devices with an iOS older than 13.4. |
So these changes changes come with a bug due to the lack of using iOS 13.4. Repo:
keyCommandTriggered will believe only the So if someone pressing |
I recommend just upgrading to iOS 13.4, so this and any other edge-cases can be avoided. |
Or at least condition the feature to only show in iOS 13.4 |
If the bug happens this frequently, it is not usable. Then unfortunately it looks like we can only make this feature available to 13.4 and above. Can you please add the code to condition this feature only to iOS 13.4 and above? Then I will do the merge, and add related documentation on it. |
…had bugs) + Cleaner implementation Repo: - In insert mode - Press and hold h - Press and hold ctrl - Release h A virtual esc key press will be injected, even before releasing ctrleyCommandTriggered will believe only the ctrl key is being pressed when you press ctrl (even though h is still be held). Then when you release h, it can't tell which key was released so it has to assume ctrl was released and thus injects a virtual esc. So if someone pressing ctrl with one hand too quickly before releasing all other keys, they're going to encounter this bug. I encountered this several times even just casually using vim. merge feature
Feature's now conditioned for versions 13.4 and up. (Though, I'm not sure how to test it on lower versions.) Also, cleaned up the implementation a bit. |
I have tested it both on iOS 13.4 and 12.4.5 (not supposed to work), and it worked like a charm. It will be included into the TestFlight testing before its final release. |
This adds a new app setting to map ctrl to esc on release. That is if ctrl (either physical or mapped by iVim/iOS) is pressed and released without any other keys pressed, it'll act as an escape key.