Hi all,
I develop with webix+cordova on mobile devices, recently I got an handheld pda device with barcode scanner. Since I do not have the specific cordova plugin, I have decided to use it in keyboard emulation mode. I have tried to catch keyboard input with a global keypress listener but it seems that webix captures the keyboard events and do not let me to analyze the input, but maybe I’m wrong.
So I created an input element at the top of the html body and moved it to an invisible position
input style=‘position: absolute; top: -1000px; left: -1000px; opacity: 0’ type=“text” id=“elemID”
and then I made three listener to force the input element focus and hide the soft keyboard when necessary:
var _DO_BLUR_ = false;
document.getElementById('elemID').onblur = function (event) {
if (!_DO_BLUR_)
return;
var me = this;
setTimeout(function () {
me.focus()
}, 10);
};
document.getElementById('elemID').onfocus = function () {
window.setTimeout(function () {
cordova.plugins.Keyboard.close();
}, 20);
};
document.getElementById('elemID').onkeypress = function (event) {
if (event.charCode = 13) {
if ($$('x_scan').isVisible() && _DO_BLUR_ )
get_bar(document.getElementById("elemID").value, 1);
document.getElementById("elemID").value = "";
}
Everything works fine, but the cons is that every webix focused input can receive the scanned code.
So I need to have a global keypress event to check the start e stop scanner characters to avoid the above cons.
Any help?
Thanks