From e6c5064ce53baee2fafcdc355653a712a66a29d7 Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:05:25 +0800 Subject: [PATCH] fix: android input, Backspace and Enter (#9782) Signed-off-by: fufesou --- flutter/lib/models/input_model.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index 2b00098ca..1b2a9736e 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -556,13 +556,14 @@ class InputModel { // The correct PhysicalKeyboardKey should be // PhysicalKeyboardKey#e14a9(usbHidUsage: "0x00070028", debugName: "Enter") // https://github.com/flutter/flutter/issues/157771 - final isKeyMatch = - isIOS || isAndroid && e.logicalKey.debugName == e.physicalKey.debugName; + // We cannot use the debugName to determine the key is correct or not, because it's null in release mode. + // to-do: `isLegacyModeKeys` is not the best workaround, we need to find a better way to fix this issue. + final isLegacyModeKeys = ['Backspace', 'Enter'].contains(e.logicalKey.keyLabel); final isMobileAndPeerNotAndroid = isMobile && peerPlatform != kPeerPlatformAndroid; final isDesktopAndMapMode = isDesktop || isWebDesktop && keyboardMode == kKeyMapMode; - if (isKeyMatch && (isMobileAndPeerNotAndroid || isDesktopAndMapMode)) { + if (!isLegacyModeKeys && (isMobileAndPeerNotAndroid || isDesktopAndMapMode)) { // FIXME: e.character is wrong for dead keys, eg: ^ in de newKeyboardMode( e.character ?? '',