Skip to content

Commit

Permalink
Fix issue with tab key
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Maurel committed Aug 12, 2013
1 parent fcfeb2a commit e0e8e82
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
@@ -1,3 +1,6 @@
1.1.2
Fix issue with tab key

1.1.1
Fix issue with $(selector).scannerDetection('scanned string')

Expand Down
16 changes: 14 additions & 2 deletions jquery.scannerdetection.js
Expand Up @@ -9,7 +9,7 @@
* Project home:
* https://github.com/julien-maurel/jQuery-Scanner-Detection
*
* Version: 1.1.1
* Version: 1.1.2
*
*/
(function($){
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down

0 comments on commit e0e8e82

Please sign in to comment.