This Flutter project demonstrates a work-around that enables hardware arrow keys in webview_flutter.
Without this work-around hardware arrow keys do not work in webview_flutter, as is outlined in flutter/flutter#102505.
The issue occurs on the following platforms:
- Android with a hardware keyboard attached
- Chromebook with hardware keyboard
- iOS with a hardware keyboard attached
Apparently the arrow keys from the hardware keyboard get "eaten" by Flutter and never reach the included webview. By listening to the arrow keys and instructing Flutter to return them to the platform the arrow keys function again.
Note: this issue was tested on Flutter 3.10.6.
- Clone this project.
- Disable the
onKey
handler of theFocus
node. - Run the project on an iOS, Android or Chromebook device with a hardware keyboard.
- Enter text in the search text field and use left and right keyboard arrow keys to move the cursor.
- Expected: cursor moves left and right.
- Actual: cursor does not move.