[FIX] point_of_sale: barcode scanner was not working in firefox due to usage of event.keyCode instead of event.which

bzr revid: fva@openerp.com-20130920094837-nks57e8qk3rgfksc
This commit is contained in:
Frédéric van der Essen 2013-09-20 11:48:37 +02:00
parent 60b17e760c
commit 885bd7ff7a
1 changed files with 6 additions and 6 deletions

View File

@ -540,10 +540,9 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
// The barcode readers acts as a keyboard, we catch all keyup events and try to find a
// barcode sequence in the typed keys, then act accordingly.
$('body').delegate('','keypress', function (e){
//console.log('keyup:'+String.fromCharCode(e.keyCode)+' '+e.keyCode,e);
this.handler = function(e){
//We only care about numbers
if (e.keyCode >= 48 && e.keyCode < 58){
if (e.which >= 48 && e.which < 58){
// The barcode reader sends keystrokes with a specific interval.
// We look if the typed keys fit in the interval.
@ -556,7 +555,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
timeStamp = new Date().getTime();
}
}
codeNumbers.push(e.keyCode - 48);
codeNumbers.push(e.which - 48);
lastTimeStamp = new Date().getTime();
if (codeNumbers.length === 13) {
//We have found what seems to be a valid codebar
@ -567,12 +566,13 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
// NaN
codeNumbers = [];
}
});
};
$('body').on('keypress', this.handler);
},
// stops catching keyboard events
disconnect: function(){
$('body').undelegate('', 'keyup')
$('body').off('keypress', this.handler)
},
});