21 lines
523 B
JavaScript
21 lines
523 B
JavaScript
(function () {
|
|
const input = document.getElementById("scan-input");
|
|
const form = document.getElementById("scan-search-form");
|
|
|
|
if (!input || !form) {
|
|
return;
|
|
}
|
|
|
|
// Keep focus for barcode scanners that type and send Enter immediately.
|
|
window.addEventListener("load", function () {
|
|
input.focus();
|
|
});
|
|
|
|
document.addEventListener("keydown", function (event) {
|
|
if (event.key === "Escape") {
|
|
input.value = "";
|
|
input.focus();
|
|
}
|
|
});
|
|
})();
|