@@ -26,11 +26,7 @@ final class HIDBarcodeParser {
2626 /// Process a key press event
2727 /// - Parameter key: The key that was pressed
2828 func processKeyPress( _ key: UIKey ) {
29- guard key. characters. isNotEmpty else {
30- // This was added to prevent a double-trigger-pull on a Star scanner from adding an error row –
31- // Star use this as a shortcut to switch to the software keyboard. They send keycode 174 0xAE,
32- // which is undefined and reserved in UIKeyboardHIDUsage. The scanner doesn't send a character with the code.
33- // There seems to be no reason to handle empty input when considering scans.
29+ guard shouldRecogniseAsScanKeystroke ( key) else {
3430 return
3531 }
3632
@@ -54,6 +50,23 @@ final class HIDBarcodeParser {
5450 }
5551 }
5652
53+ private func shouldRecogniseAsScanKeystroke( _ key: UIKey ) -> Bool {
54+ guard key. characters. isNotEmpty else {
55+ // This prevents a double-trigger-pull on a Star scanner from adding an error row –
56+ // Star use this as a shortcut to switch to the software keyboard. They send keycode 174 0xAE, which is
57+ // undefined and reserved in UIKeyboardHIDUsage. The scanner doesn't send a character with the code.
58+ // There seems to be no reason to handle empty input when considering scans.
59+ return false
60+ }
61+
62+ if buffer. isEmpty && configuration. terminatingStrings. contains ( key. characters) {
63+ // We prefer to show all partial scans, but if we just get an enter with no numbers, ignoring it makes testing easier
64+ return false
65+ }
66+
67+ return true
68+ }
69+
5770 private let excludedKeys : [ UIKeyboardHIDUsage ] = [
5871 . keyboardCapsLock,
5972 . keyboardF1,
0 commit comments