当前位置:网站首页>界面仅允许扫码枪录入禁止手工键盘输入
界面仅允许扫码枪录入禁止手工键盘输入
2022-08-03 05:27:00 【谷凯Jump】
由于扫码枪和键盘都属于外设,对于应用程序来说,无法判断输入源。
可间接的通过按键时间来判断。
扫码枪速度大概在0-50ms之间,平均在8ms左右,手动输入在100-200之间,除非特地快速输入可达到30几ms。
我们取个适中的时间:50ms
DateTime dStart;
DateTime dEnd;
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
dStart = DateTime.Now;
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
dEnd = DateTime.Now;
if ((dEnd - dStart).TotalMilliseconds > 50) { textBox1.Clear(); }
}边栏推荐
猜你喜欢
随机推荐
5. What is the difference between int and Integer?
2021-06-20
MySQL的主从复制
Dynamic adjustment of web theme (2) Extraction
SolidWorks 操作视频 | 隐藏高手必备工具Defeature,让设计隐藏更彻底
SQLMAP介绍及使用
ZEMAX | 如何使用渐晕系数
6. What is the difference between Vector, ArrayList and LinkedList?(design, performance, safety)
【记录】把json的所有key转换成小写
SSL证书过期后怎么办?
MATLAB给多组条形图添加误差棒
2021-06-15
NIO知识汇总 收藏这一篇就够了!!!
【面筋1】一些没什么标准答案的问题
ue4学习日记4(植被,光照,光束遮挡,天空球)
9. Please introduce the class loading process, what is the parent delegation model?
小程序动态加载分包文件及根路径处理
Practice of MySql's Sql statement (try how many you can write)
Makefile.am:24: error: Libtool library used but ‘LIBTOOL‘ is undefined
数组与字符串13-两数之和等于目标数









