I'm trying to create shortcuts that open other windows, but the keys get stuck if you're pressing when the window loses focus.
Steps to Reproduce
- Run
flutter create bug.
- Update the files as follows:
// main.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final _node = FocusNode();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: SafeArea(
child: RawKeyboardListener(
child: Center(
child: Text('Hold Ctrl+A'),
),
focusNode: _node,
autofocus: true,
onKey: (rawKeyEvent) {
if (rawKeyEvent.isKeyPressed(LogicalKeyboardKey.keyA) &&
rawKeyEvent.isKeyPressed(LogicalKeyboardKey.controlLeft)) {
launch('https://flutter.dev/');
}
},
),
),
),
);
}
}
- Run the app, press and hold Ctrl+A. Wait to open the link in your browser. Go back to the app and just press Ctrl.
Expected results:
Pressing only Ctrl should do nothing
Actual results:
The link opens again in the browser
flutter doctor -v
[✓] Flutter (Channel master, 1.26.0-2.0.pre.355, on Microsoft Windows [versão
10.0.19042.685], locale pt-BR)
• Flutter version 1.26.0-2.0.pre.355 at D:\Programming\libs\flutter
• Framework revision 2a64fdbc43 (2 hours ago), 2021-01-14 17:39:03 -0600
• Engine revision effb529ece
• Dart version 2.12.0 (build 2.12.0-224.0.dev)
[✓] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.2)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community
• Visual Studio Community 2019 version 16.8.30717.126
• Windows 10 SDK version 10.0.18362.0
[✓] VS Code (version 1.51.0)
• VS Code at C:\Users\srodr\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.17.0
[✓] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [versão
10.0.19042.685]
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.141
• Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.60
• No issues found!
My app uses shortcuts and actions from MaterialApp to open other windows, but it has the same behavior. From my tests, it seems that a KeyUpEvent is not captured when the window loses focus. It may be related to #48899 or #66588.
I'm trying to create shortcuts that open other windows, but the keys get stuck if you're pressing when the window loses focus.
Steps to Reproduce
flutter create bug.Expected results:
Pressing only Ctrl should do nothing
Actual results:
The link opens again in the browser
flutter doctor -v
My app uses shortcuts and actions from MaterialApp to open other windows, but it has the same behavior. From my tests, it seems that a KeyUpEvent is not captured when the window loses focus. It may be related to #48899 or #66588.