Created
February 9, 2026 16:57
-
-
Save thomasdarimont/5f9f4d090320663be299f16da3e43065 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <div> | |
| <span>A</span> | |
| <input type="text" id="inputWithKeyboard"> | |
| </div> | |
| <div> | |
| <span>B</span> | |
| <input id="inputWithoutKeyboard" type="text" readonly autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"> | |
| </div> | |
| <style> | |
| input { | |
| font-size: 32px; | |
| } | |
| </style> | |
| <script> | |
| const code = document.getElementById("inputWithoutKeyboard"); | |
| function armScannerFocus() { | |
| code.setAttribute("readonly", ""); // suppress IME | |
| code.focus({ preventScroll: true }); | |
| // first real input from scanner -> enable editing | |
| const enable = () => { | |
| code.removeAttribute("readonly"); | |
| code.removeEventListener("keydown", enable); | |
| code.removeEventListener("beforeinput", enable); | |
| }; | |
| code.addEventListener("keydown", enable, { once: true }); | |
| code.addEventListener("beforeinput", enable, { once: true }); | |
| } | |
| armScannerFocus(); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment