flutter-webview-windows icon indicating copy to clipboard operation
flutter-webview-windows copied to clipboard

Controlling Input-Fields without Hardware-Keyboard in WebView

Open Eerey opened this issue 2 years ago • 4 comments

Hello there, I want to be able to use a Virtual Keyboard (Overlay) in combination with this plugin, but I cannot send KeyPressed-Events to the WebView. What options do I have if my customer will not have any hardware keyboard?

I saw that it is possible to execute JavaScript with this plugin, but it seems that for security reasons it is not allowed to simulate keystrokes programatically.

Note: Manually firing an event does not generate the default action associated with that event. For example, manually firing a key event does not cause that letter to appear in a focused text input. In the case of UI events, this is important for security reasons, as it prevents scripts from simulating user actions that interact with the browser itself.

Here's a StackOverflow-question regarding the KeyPress-Events.

Eerey avatar Mar 06 '22 16:03 Eerey

My current solution is to load jquery and manipulate the input-values. But this feels very insecure and not clean at all.

Eerey avatar Mar 09 '22 10:03 Eerey

Unfortunately, WebView2 doesn't provide an API for submitting keypress events. So I don't think there's a better way than using JS.

jnschulze avatar Mar 09 '22 12:03 jnschulze

Is it possible to expose javascript-variables to dart/flutter?

Eerey avatar Mar 09 '22 12:03 Eerey

@jnschulze do you think it's possible to inject an entire javascript overlay keyboard like this? https://virtual-keyboard.js.org/

Could this break? What are the advantages? What are the drawbacks?

Eerey avatar Mar 24 '22 13:03 Eerey