初次提交项目
This commit is contained in:
20
static/js/scanner.js
Normal file
20
static/js/scanner.js
Normal file
@@ -0,0 +1,20 @@
|
||||
(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();
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user