Tuesday, March 4, 2014

Capture RFID Scanner on webpage without input

$(document).ready(function(){

    var arr = [];
   
    $(this).bind('keypress', function(e){
    
        var code = e.keyCode || e.which;
   
        if(code == 13) { //Enter keycode
            console.log(arr.join('',','));
            console.log('Press Enter');
            arr = [];
        } else {
            // convert each kepress to character and add to array
            arr.push(String.fromCharCode(e.keyCode));
        }
    });
});

No comments:

Post a Comment