Reputation: 59
I am trying to find a way to send keyboard events from my flutter app to a WebView that I have open in app. For example, the WebView has some JS code with an Observer that waits for key events to happen. Any idea how could I do that?
Upvotes: 2
Views: 1171
Reputation: 59
UPDATE: For any future adventurers that find their way here, I must dissapoint you. I figured out that sending keystroke events is forbidden in Android due to security reasons (duh). You can only use it in testing libraries. Reason being that your system would be very exposed if an app allowed keystroke events as input.
You are better off calling a deeplink to open a browser, or scrapt the native app altogether if you want to link it to a web-app.
Those were my two cents after working on web and native development for the last 2 years.
Upvotes: 1
Reputation: 359
You can use the KeyboardListener class and send the data on the WebView javaScriptChannels property (considering you are using webview_flutter package).
Upvotes: -1