Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@vkjon
Copy link

@vkjon vkjon commented May 19, 2019

Following the discussion in #8606, this PR implements a key event channel to pass key press events (from TextFields) in iOS.

References flutter/flutter#29845

@stuartmorgan @cbracken @gspencergoog

@vkjon vkjon changed the title Impl. key event channel for iOS (flutter/flutter#29845) Impl. key event channel for iOS Jun 5, 2019
@gspencergoog
Copy link
Contributor

In re-reading this, I realized that this PR is only for sending the backspace key, right? That's not really all that useful in the broader scheme of things. Ideally, there would be support for all the keys on the keyboard, like the other platforms. Is that just not feasible, or is there other work to be done for that? And if so, what needs to be done?

@vkjon
Copy link
Author

vkjon commented Jun 5, 2019

Lol, yes sorry to disappoint. :D

Unfortunately, iOS's doesn't expose key events to us, as the other platforms do. We are strictly limited by the callbacks exposed by UIKeyInput,(void)deleteBackward; and (void)insertText:(NSString *)text; to simulate key press events.

I thought about reversing any text received in (void)insertText:text into their key code equivalents, but that seems like that would be a significant undertaking. I am not sure of the challenges one might encounter dealing with various languages.

In any case, this PR should serve as a starting point, if we decide to take on that task.

@cbracken
Copy link
Member

@snowxd thanks for your contribution. I'd prefer not to merge something with only a partial implementation. I agree that an implementation that can 'reverse engineer' out the key events required to get from state A to state B is likely to be a significant undertaking.

@gspencergoog @stuartmorgan how would you like to proceed on this?

@stuartmorgan-g
Copy link
Contributor

@cbracken I think you and/or @gspencergoog are the right people to figure out how to proceed with this/#8606 based on the discussion in the two bugs. I was originally looped in to weigh in on similarities with desktop work on key events, but the fundamental limitation discussed above doesn't apply to desktop, so this is now specifically a question of what the best way to handle iOS.

@cbracken
Copy link
Member

Sounds good.

@snowxd just to set expectations, @gspencergoog is out for a couple weeks and I'll be out starting next week until mid-July, but we'll sync up then and get back on this. Apologies for the latency.

@vkjon
Copy link
Author

vkjon commented Jul 9, 2019

Hey, no worries.

I was playing around with javascript KeyEvents in Chrome, on iOS, and I noticed that they take a simple approach ignoring modifiers and non-ascii characters (?). I think replicating the same behavior by reversing (void)insertText:text to emulate key press would be a good direction to take.

Essentially, we would reverse every character received to their ASCII equivalent and map that to their key code. Lowercase and uppercase characters would map to the same key code.

@cbracken
Copy link
Member

cbracken commented Aug 5, 2019

Given that we don't plan to take this PR in its current partial implementation, I'm going to close this for now. We'd absolutely welcome an implementation that emits synthesized key events based on diffs between strings though. Thanks for your contribution!

@cbracken cbracken closed this Aug 5, 2019
@gspencergoog
Copy link
Contributor

@snowxd, the final approach you mention sounds interesting, but I think (as you mentioned above) that it might have significant problems when trying to support various non-ASCII keys. If you can find a way, though, we'd love to see it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants