当前位置:网站首页>Shutter web hardware keyboard monitoring
Shutter web hardware keyboard monitoring
2022-07-05 06:08:00 【bawomingtian123】
Flutter web Use keyboard monitoring when developing pages , I found a circle on the Internet and recommended it RawKeyboardListener Components
However, in the actual development process, it is found that the component often fails, resulting in the inability to monitor keyboard input .
Now the solution , Use HardwareKeyboard object .
How to get HardwareKeyboard Single case , Then add your own callback method
late HardwareKeyboard hardwareKeyboard;
@override
void initState() {
hardwareKeyboard = HardwareKeyboard.instance;
hardwareKeyboard.addHandler((event) {
print("event=${event.toStringShort()}");
return true;
});
super.initState();
}
In this way, the hardware keyboard input can be monitored every time .
event=KeyDownEvent#b9cb2
event=KeyUpEvent#b073c
event=KeyDownEvent#8425d
event=KeyUpEvent#b8cec
event=KeyDownEvent#3c7a9
event=KeyUpEvent#c0b31
event=KeyDownEvent#9d155
event=KeyUpEvent#9b0ca
event=KeyDownEvent#5bd0b
event=KeyUpEvent#e8fdf
event=KeyDownEvent#78c1b
event=KeyUpEvent#0abb7
The log table output is as above , We can totally rely on event Object to determine the current key input , Very convenient .
边栏推荐
猜你喜欢
随机推荐
Binary search template
1.13 - RISC/CISC
Graduation project of game mall
Educational codeforces round 109 (rated for Div. 2) C. robot collisions D. armchairs
实时时钟 (RTC)
1.15 - 输入输出系统
Overview of variable resistors - structure, operation and different applications
QQ电脑版取消转义符输入表情
【Rust 笔记】16-输入与输出(下)
MIT-6874-Deep Learning in the Life Sciences Week 7
Smart construction site "hydropower energy consumption online monitoring system"
【实战技能】非技术背景经理的技术管理
2022 极术通讯-Arm 虚拟硬件加速物联网软件开发
Matrixdb V4.5.0 was launched with a new mars2 storage engine!
【Rust 笔记】13-迭代器(下)
LeetCode 0107.二叉树的层序遍历II - 另一种方法
F - Two Exam(AtCoder Beginner Contest 238)
Daily question 1688 Number of matches in the competition
SQLMAP使用教程(一)
Over fitting and regularization