当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - 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). 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. I tried <textarea> as well, but with no luck. How to tackle this issue?

网友答案:

I did this with a barcode scanner that could not append CR.

What I did was start a timer to timeout in 500 milliseconds after receiving the first character. 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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: