From 6fb8cb47568c7935ebe445b86a5d2181d0107152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 18 Sep 2013 17:33:47 +0200 Subject: [PATCH] [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 --- addons/point_of_sale/static/src/js/devices.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index d36fd6277ed..0326d71d792 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -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) }, });