-
-
Save parzibyte/6e88860485a6dfa04e88e121974231b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("DOMContentLoaded", () => { | |
const $codigo = document.querySelector("#codigo"); | |
$codigo.addEventListener("keydown", evento => { | |
if (evento.keyCode === 13) { | |
// El lector ya terminó de leer | |
const codigoDeBarras = $codigo.value; | |
// Aquí ya podemos hacer algo con el código. Yo solo lo imprimiré | |
console.log("Tenemos un código de barras:"); | |
console.log(codigoDeBarras); | |
// Limpiar el campo | |
$codigo.value = ""; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment