[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-20130918153347-fy4nuvbm82ngfb8x
This commit is contained in:
parent
130afb812d
commit
6fb8cb4756
|
@ -437,10 +437,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.
|
||||
|
@ -453,7 +452,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
|
||||
|
@ -464,12 +463,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)
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue