diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2af7a9c..bd85e3e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,6 @@ +1.1.2 + Fix issue with tab key + 1.1.1 Fix issue with $(selector).scannerDetection('scanned string') diff --git a/jquery.scannerdetection.js b/jquery.scannerdetection.js index 593aa76..605ff47 100644 --- a/jquery.scannerdetection.js +++ b/jquery.scannerdetection.js @@ -9,7 +9,7 @@ * Project home: * https://github.com/julien-maurel/jQuery-Scanner-Detection * - * Version: 1.1.1 + * Version: 1.1.2 * */ (function($){ @@ -69,7 +69,19 @@ return false; } } - $self.data('scannerDetection',{options:options}).unbind('.scannerDetection').bind('keypress.scannerDetection',function(e){ + $self.data('scannerDetection',{options:options}).unbind('.scannerDetection').bind('keydown.scannerDetection',function(e){ + // Add event on keydown because keypress is not triggered for non character keys (tab, up, down...) + // So need that to check endChar (that is often tab or enter) and call keypress if necessary + if(firstCharTime && options.endChar.indexOf(e.which)!==-1){ + // Clone event, set type and trigger it + var e2=jQuery.Event('keypress',e); + e2.type='keypress.scannerDetection'; + $self.triggerHandler(e2); + // Cancel default + e.preventDefault(); + e.stopImmediatePropagation(); + } + }).bind('keypress.scannerDetection',function(e){ if(options.stopPropagation) e.stopImmediatePropagation(); if(options.preventDefault) e.preventDefault(); diff --git a/scannerdetection.jquery.json b/scannerdetection.jquery.json index 10026ba..0bbc306 100644 --- a/scannerdetection.jquery.json +++ b/scannerdetection.jquery.json @@ -1,6 +1,6 @@ { "name": "scannerdetection", - "version": "1.1.1", + "version": "1.1.2", "title": "jQuery Scanner Detection", "author": { "name": "Julien Maurel",