admin 管理员组文章数量: 1086019
I have a page for a barcode scanner(honeywell ct50) running Android 4.4.4, The soft keyboard pops up automatically as input textbox is on focus. Is there any solution to hide it? I have read suggestions, mostly making the input losing focus or being readonly, but I need to keep the focus on the input to read the barcode.
I tried 1. to execute event.preventDefault() in onfocus event, it doesn't work. 2. to get the barcode on document.keypress(), the solution in the post as below, but nothing got from my scanner. javascript - hide mobile default keyboard but keep input field active
Any ideas are wele.
I have a page for a barcode scanner(honeywell ct50) running Android 4.4.4, The soft keyboard pops up automatically as input textbox is on focus. Is there any solution to hide it? I have read suggestions, mostly making the input losing focus or being readonly, but I need to keep the focus on the input to read the barcode.
I tried 1. to execute event.preventDefault() in onfocus event, it doesn't work. 2. to get the barcode on document.keypress(), the solution in the post as below, but nothing got from my scanner. javascript - hide mobile default keyboard but keep input field active
Any ideas are wele.
Share Improve this question asked Feb 6, 2018 at 4:29 Charlene FengCharlene Feng 811 silver badge3 bronze badges 2- why are you referring to javascript? Is it not a native application? – Chisko Commented Feb 6, 2018 at 5:05
- 1 Have you found a solution, we've ran into the same problem in a Web App that uses barcode scanner on the same device and need to hide the keyboard while keeping focus on a text field – pixelwiz Commented Jun 8, 2018 at 13:33
2 Answers
Reset to default 5Old topic but this is the solution which works at least for android 6 and 7:
yourInput = document.getElementById('yourInputElement');
yourInput.readOnly = true;
yourInput.focus();
setTimeout(function(){document.getElementById('yourInputElement').readOnly = false;}, 50);
You put your input in readOnly = true before the focus.
The keyboard will not appear.
And you put back the input in readOnly = false but not immediately.
So you can use your scanner without having the keyboard popping up.
For me what worked at some point was setting the ion-input type="text" to readonly, but now it is not working when setting that property. Maybe give it a try.
本文标签: javascriptHow to hide soft keyboard and keep input on focusStack Overflow
版权声明:本文标题:javascript - How to hide soft keyboard and keep input on focus - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744035111a2522219.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论