This is expected behavior, all. At the core of the regex match is the data that we receive from a JavaScript KeyboardEvent because this executes in the scope of the browser. We’re assembling a character sequence to match against from an input source (your barcode scanner) that creates KeyboardEvents. A “new line” character shows up as a key press for the “Enter” key.
https://keycode.info/ is a pretty decent way to test what KeyboardEvent data your sequence would produce. It tests a key at a time, but knowing what your sequence looks like, you could type it out on your keyboard to generate the KeyboardEvent and observe the event.key
value in the tool.