Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
¿Cómo manejar shift presionado antes de otra tecla en onkeyup?

Necesito manejar el escáner de código de barras usb en mi página web, todo funcionaba bien en mi computadora, pero cuando lo probé en otra (Windows 7 y otro escáner) tuve un problema con la tecla Mayús.

El código de barras del escáner tiene : símbolo y cuando se lee se pasa como Shift; ¿Cómo puedo obtener el símbolo real de él?

Aquí está mi función cuando manejo el escaneo:

 document.addEventListener("keyup", (event) => { let key = event.key; if (event.isComposing || key === 'Shift' || key === 'Control' || key === 'Meta' || key === 'Alt') { return; } if (containerLoading.classList.contains("d-none")) { showLoading(); } if (!containerLoading.classList.contains("d-none")) { if (key === "Enter" || key === "Tab") { if (barcode != "") { websocket.send(`<ART>${barcode}</ART>`); barcode = ""; } } else { barcode += key; } } });

Así es como el código de barras del escáner da como resultado el bloc de notas (y así es como debería ser) y debajo puede ver cómo se ve en el navegador:

ingrese la descripción de la imagen aquí

TEXTO DE PRUEBA:

EQUIVOCADO

 Hc1ò6BFOXN%Ts3DHPVo13j -g'-2YRVa.q-r8'd32Fc1j9M$Di9CPi9ELNLAPS$SçLc-GPWBILc9Ff9 84Ev28JVSAp921TDUMx6WUKAMa800p92ò3

CORRECTO

 HC1ç6BFOXN%TS3DHPVO13J -G'-2YRVA.Q-R8'D32FC1J9M$DI9CPI9ELNLAPS$SçLC-GPWBILC9FF9 (4EV28JVSAP921TDUMX6WUKAMA800P92ç3

TECLADO ESP

 HC1:6BFOXN%TS3DHPVO13J /G-/2YRVA.Q/R8-D32FC1J9M$DI9CPI9ELNLAPS$S:LC/GPWBILC9FF9 *4EV28JVSAP921TDUMX6WUKAMA800P92:3
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Resuelto reemplazando keyup con keypress

Ahora el código se ve así:

 document.addEventListener("keypress", (event) => { let key = event.key; if (event.isComposing || key === 'Shift' || key === 'Control' || key === 'Meta' || key === 'Alt') { return; } if (containerLoading.classList.contains("d-none")) { showLoading(); } if (!containerLoading.classList.contains("d-none")) { if (key === "Enter" || key === "Tab") { if (barcode != "") { websocket.send(`<ART>${barcode}</ART>`); barcode = ""; } } else { barcode += key; } } });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!