Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

298
Vistas
How to capture barcode hex code keystrokes in an input tag

I have a Datalogic Memor10 barcode scanner which looks and acts a lot like an Android phone, except that additionally it has a barcode scanner in the front. The barcode scanner can be triggered by pressing a key on the side of the Memor10. It also has a feature it calls a Keyboard Wedge which is luckily enabled by default, since I was unable to figure out how to get its complicated settings to be changed. The Keyboard Wedge apparently causes any scanned barcode to also be typed as keystrokes; so that, for example, when you have an input tag on a web application it will type the barcode into that input as keystrokes.

This works great for simple barcodes, however the barcode I would like to scan is an South African drivers license barcode which is encrypted with RSA encryption and therefore the keystrokes returned could be any byte character. This is a problem, since keystrokes such as Tab and Enter would leave the input field or submit by default.

The included form tag is only to prevent Oracle Apex's native form submission.

I have tried unsuccessfully to prevent this and just get the byte codes as hex characters with a simple input screen in Oracle Apex. My Javascript/jQuery/HTML code is currently the following:

Static content region:

<form method="POST" action="javascript:void(0);">
   <input type="text" id="barcode" name="barcode">
</form>

On page load:

/*
$("#barcode").on('keyup', function(e) {
    console.log(e.keyCode.toString(16));
    e.preventDefault();
});
*/
$("#barcode").keypress(function(event) {
   console.log(event.which.toString(16));
   event.preventDefault();
});

However this does not work well, since Tab still leaves the input field and Enter works the first time and then stops working, only to start working again if you press another key inbetween. Not sure which other byte codes would cause issues. What code can I use to successfully capture the long string of byte codes sent as keystrokes to the input tag by the Memor10 barcode scanner? Or is there some other way of achieving this? I would like this to be a web application and not an Android native app.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The keypress event is fired when a character value is pressed down. Also, it is deprecated. You should use the keydown event, which is fired for all keys.

<form method="POST" action="javascript:void(0);">
  <input type="text" id="barcode" name="barcode">
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
  
/*$("#barcode").on('keyup', function(e) {
    console.log(e.keyCode.toString(16));
    e.preventDefault();
});*/

$("#barcode").on('keydown',function(event) {
   console.log(event.which.toString(16));
   event.preventDefault();
});
</script>

This first snippet will help you prevent the tab character from causing damage.

Next, to see if there are issues with other key codes, I wrote a script which will fire an event for all key codes from 0 to 256.

$("#barcode").on('keydown',function(event) {
   console.log(event.keyCode.toString(16));
   event.preventDefault();
});

const el = document.getElementById('barcode')
for (let i = 0; i < 256; ++i) {
  el.dispatchEvent(new KeyboardEvent('keydown',{'keyCode':i}));
}
<form method="POST" action="javascript:void(0);">
  <input type="text" id="barcode" name="barcode">
</form>
<script
  src="https://code.jquery.com/jquery-3.6.0.slim.min.js"
  integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI="
  crossorigin="anonymous"></script>

It seems to work. Now you can gather all key strokes in an array to recompose your bar code.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda