JavaScript keyPress.which shows more codes than what barcode scanner outputs

When I use a barcode scanner in a normal notepad, it scans a code like this: 2000000415369. When I create an input field in HTML and put focus into that field and scan a barcode, it still outputs the correct code.

Now when I create a javascript listener to capture the code, to make sure, in javascript, that the input came from a barcode scanner, the keyPress event.which string outputs a lot more characters than what is described above. I get this in my console output:

0|5|0|2|0|4|8|0|0|4|8|0|0|4|8|0|0|4|8|0|0|4|8|0|0|4|8|0|0|5|2|4|0|4|9|1|0|5|3|5|0|5|1|3|0|5|4|6|0|5|7|9|

where every keycode has been changed into its keyboard value. When you compare the two scanned codes, you'll see that the correct barcode is contained within the longer scanned code. Every correct character is separated by 3 additional numbers:

050 2 048 0 048 0 048 0 048 0 048 0 048 0 052 4 049 1 053 5 051 3 054 6 057 9

Does anybody have any clue what is going on here? I'm at a complete loss why the keyPress event would capture more numbers pressed than the input field. I also tested with a normal keyboard and typing would result in only the correct pressed character to be outputed to the console.

Below is the javascript code I use for capturing the keyPress event:

$(document.body).on('keypress',function(e){
    aScannedEan.push(String.fromCharCode(e.which));
});

console.log(aScannedEan.join("|"));
Answer:1

I have an HTML table and I want to mark cells by adding a class to the highest and lowest value of each column. I have found a few related questions here, but the code misbehaves. var $table = $("#...

I have an HTML table and I want to mark cells by adding a class to the highest and lowest value of each column. I have found a few related questions here, but the code misbehaves. var $table = $("#...

First of all, word of explanation: I'm new to all this Meteor stuff so it might be a stupid question. In my Meteor code I have a template: <template name="hour_form"> <form id="add_hours"&...

First of all, word of explanation: I'm new to all this Meteor stuff so it might be a stupid question. In my Meteor code I have a template: <template name="hour_form"> <form id="add_hours"&...

I'm new to JavaScript server developement. I recognized the "mean" stack. MongoDB, Express.js, Angular.js and node.js. Where is the difference between express.js and anguar.js and do I need both at ...

I'm new to JavaScript server developement. I recognized the "mean" stack. MongoDB, Express.js, Angular.js and node.js. Where is the difference between express.js and anguar.js and do I need both at ...

  1. where difference between two dates sql
  2. where difference between were
  3. which difference between plant and animal cells
  4. which difference between weather and climate
  5. which difference between data and information
  6. which difference between stocks and bonds
  7. which difference between empathy and sympathy
  8. which difference between a city and a town
  9. which difference between authentication and authorization
  10. where is difference between visa and mastercard
  11. where is difference threshold
  12. where is the difference between peanut butter and jam
  13. where is the difference between college and university
  14. where is the difference between jail and prison
  15. where is the difference between mitosis and meiosis
  16. where is the difference between a psychologist and a psychiatrist
  17. where is the difference between a sociopath and a psychopath
  18. where is the difference between there and their
  19. where is the difference between vegetarian and vegan
  20. where is the difference between a typhoon and a hurricane

I have a form with a bunch of text elements, some of which have a data attribute set. I want to loop through all the elements that have that attribute, extracting the attribute. I've created a ...

I have a form with a bunch of text elements, some of which have a data attribute set. I want to loop through all the elements that have that attribute, extracting the attribute. I've created a ...

  1. find elements that sum to a given value
  2. find elements in selenium
  3. find elements in list python
  4. find elements in array matlab
  5. find elements in array javascript
  6. find elements in array python
  7. find elements in selenium python
  8. find elements in array with given sum
  9. find elements in matrix matlab
  10. find elements in numpy array
  11. find elements in vector c++
  12. find elements in cell array matlab
  13. find elements in selenium c#
  14. find elements in vector matlab
  15. find elements in appium
  16. find elements in array
  17. find elements in protractor
  18. find elements in array java
  19. find elements in page factory
  20. find elements in selenium java