0

im writing a php pos system for my store, and im dealing with the barcode system now.

basically i want to be able to monitor the window, and when the barcode comes in put it in the input search box and submit it.

the 2nd part is the easy part, im having difficulty with the first part.

i made the scanner append te pipeline charecter (|) to the barcode, and i have jquery monitoring the window for any key presses that are pipeline, but how would i read the key presses after the pipeline once its triggered? maybe i have the wrong approach to this..?

4

1 回答 1

1

上次我构建类似的东西时,页面有一个很大的胖<input>元素,它是自动聚焦的。您的扫描仪充当键盘,除了将字符串粘贴到一个事件中,而不是为每个不同的字符发出键事件。(至少我们的扫描仪是这样)。

添加一个<input>元素,聚焦它。当您的扫描仪发送代码时,它将被写入<input>. 在那里,您可以对事件做出反应,以查看代码keyup是否change已完整编写,然后做出相应的反应。在我们的例子中,一个换行符 ( \n) 被附加到代码中以标记它的结束。但我想管道 ( |) 也可以。

于 2012-07-02T07:49:39.603 回答