Windows10 [Flutter桌面]中的RawKeyEvent错误字符 [英] RawKeyEvent wrong characters in Windows10 [Flutter desktop]
问题描述
我正在Flutter Desktop
项目(Windows 10)中测试RawKeyboardListener
.
I'm testing RawKeyboardListener
in a Flutter Desktop
project (Windows 10).
事件运行正常,但是我收到了错误的按键标签,如下所示:
Events work fine, but i receive wrong keys label, as you can see below:
这是否是键盘布局"问题,例如应用程序是否期望来自具有不同键位置的android键盘事件(如您在我收到的.gif和未知的Android键代码"中所看到的)? 我该如何解决?
Is it a "keyboard layout" issue, like if the app was expecting events from an android keyboard with different key positions (As you can see in the .gif i receive and "Unknown Android key code")? How can i fix that?
此外,如果我打印event.isControlPressed
,即使我按它也总是返回false
.
Also, if i print event.isControlPressed
it always return false
even if i'm pressing it.
这是我正在使用的代码:
This is the code i'm using:
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
if (!kIsWeb && (Platform.isLinux || Platform.isWindows)) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: RawKeyboardListener(
child: TextField(),
focusNode: FocusNode(),
onKey: (event) async {
if (event.runtimeType == RawKeyDownEvent) {
print(
'id: ${event.logicalKey.keyId}, label: ${event.logicalKey.keyLabel} debugName: ${event.logicalKey.debugName}');
}
},
),
),
);
}
}
推荐答案
That's a bug. There's nothing you can do at the level of your application to fix it.
在修正之前,您唯一可以做的就是完全根据键码而不是逻辑键来编写键处理.
Until it's fixed, the only thing you could do would be to write your key handling entirely in terms of key codes, rather than logical keys.
这篇关于Windows10 [Flutter桌面]中的RawKeyEvent错误字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!