简体   繁体   English

Javascript密码

[英]Javascript keycodes

I am facing is weird problem. 我面临的是奇怪的问题。 I have an input field on my page which gets its feed from a barcode scanner which appends a carriage return at the end (keycode: 13). 我在页面上有一个输入字段,该字段是从条形码扫描仪获取的提要,该扫描仪在末尾附加了回车符(键码:13)。 When I use my scanner on a regular notepad, Once the input prints on screen, the cursor moves to the next line (it gets the carriage return), where as if I do the same thing on the <INPUT> tag, it never gives the carriage return. 当我在常规记事本上使用扫描仪时,一旦在屏幕上打印输入内容,光标就会移到下一行(它将获得回车符),就像我在<INPUT>标签上执行相同的操作一样,它永远不会给出回车。 I tried <textarea> as well, but with no luck. 我也尝试了<textarea> ,但是没有运气。 How to tackle this issue? 如何解决这个问题?

I did this with a barcode scanner that could not append CR. 我使用无法附加CR的条形码扫描仪进行了此操作。

What I did was start a timer to timeout in 500 milliseconds after receiving the first character. 我所做的就是在收到第一个字符后启动计时器以在500毫秒内超时。 After receiving each additional character, I'd reset the timer. 收到其他每个字符后,我将重置计时器。 When the timeout occurs, it submits the form. 发生超时时,它将提交表单。

So once it stops receiving characters, it submits the form. 因此,一旦停止接收字符,它将提交表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM