在Flex中,如何捕获读卡器的输入而不影响其他按键输入?
需要创建一个从读卡器读取输入的应用程序。
来自读卡器的输入作为字符串,类似于键盘事件。在flex中,我可以通过监听按键事件来捕获这个字符串。
问题是,当有人从读卡器刷卡时按下按键。两者都将附加在输入中。我该如何解决这个问题?请建议。
-阿布舍克
Need to create a application which reads input from card reader.
Input coming from card reader as strings which is similar to the keyboard event. In flex,I can catch this string by listening key event.
Problem is that when someone presses key while swiping a card from card reader. Both will be appended in the input. How can i resolve this? Please suggest.
-Abhishek
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
读卡器是否使用任何类型的密钥代码?实际的按键事件具有 charCode 属性,以便您可以通过编程方式判断按下了哪个键。找出您的读者正在回击的 charCode,然后仅在事件与该 charCode 匹配时追加。
实际上,您应该追踪键盘事件,看看您能找到什么独特之处,像 keyLocation 这样的属性可能有助于识别来自阅读器和键盘的内容。
如果所有其他方法都失败了,您可以要求用户做一些几乎可以阻止他们同时打字的事情,例如在读卡时按住 alt 键。在这种情况下,您可以在事件期间检查 altKey 是否为 true。
Does the card reader use any kind of key code? An actual key press event has a charCode property so that you can programatically tell which key was pressed. figure out what charCode your reader is kicking back and then only append when the event matches that charCode.
Really you should just trace out the keyboard event and see what you can find unique about it, properties like keyLocation might help identify what's coming from the reader vs the keyboard.
If all else fails you can make it a requirement that the user do something that would pretty much prevent them from typing at the same time like holding the alt key down while they read a card. in which case you can check if altKey is true during the event.