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 welcome.
Old 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With