admin管理员组文章数量:1425913
I configured the scanner to send Enter at the end of the input and js reads it correctly but the other characters are lost.
I have tried to decode the input characters with event.keyCode, event.which, event.charCode and nothing works. If I attach it to normal input it works. It also works in the browser address bar (chrome). But when I attach it to the document['onkeypress'] it doesn't read the characters.
I tried Martin Orth solution from here: but I couldn't make it work I even don't know if it's the same scanner.
From here I understood that the scanner is sending ASCII characters and javascript has no mechanizm to read them?
If anyone knows the solution to this problem, help is highly appreciated. I prefer with js/jquery if it is possible at all.
I configured the scanner to send Enter at the end of the input and js reads it correctly but the other characters are lost.
I have tried to decode the input characters with event.keyCode, event.which, event.charCode and nothing works. If I attach it to normal input it works. It also works in the browser address bar (chrome). But when I attach it to the document['onkeypress'] it doesn't read the characters.
I tried Martin Orth solution from here: https://developer.zebra./thread/35513 but I couldn't make it work I even don't know if it's the same scanner.
From here I understood that the scanner is sending ASCII characters and javascript has no mechanizm to read them? https://developer.zebra./thread/34536
If anyone knows the solution to this problem, help is highly appreciated. I prefer with js/jquery if it is possible at all.
Share Improve this question edited Oct 2, 2019 at 20:55 DelphiCoder 2,0171 gold badge17 silver badges27 bronze badges asked Feb 19, 2019 at 14:30 martomarto 4601 gold badge5 silver badges17 bronze badges2 Answers
Reset to default 4What this code does is it creates an input focuses on it, but absolutely positions off screen becacuse IE has a problem with focusing on hidden text fields. Then detects changes to the input and outputs that for now to console.
$(document).ready(function(){
$(".scanner-input").focus().on("input",function(){
let barcode = $(this).val();
console.log(barcode);
$(this).val("");
}).blur(function(){
$(this).focus();
});
});
.scanner-input{position:absolute;left:-10000px;}
<script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" class="scanner-input">
This feature, using keypress, was recently added to DataWedge 7.3 which is included in the latest MC33 OS update (02.13.15 - LG Update 16) - I wrote a blog about how to use it: https://developer.zebra./blog/listening-keypress-events-datawedge. For clarity, I work for Zebra
本文标签:
版权声明:本文标题:jquery - How to catch input on document[keypress] on window in javascript from Zebra mc330m scanner? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745446336a2658680.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论