diff --git a/README.md b/README.md index 5f1efdd..293cf86 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ class Test extends Component { | stopPropagation | bool | false | Stop immediate propagation on keypress event | preventDefault | bool | false | Prevent default action on keypress event | testCode | string | | Test string for simulating +| preventScanOnInput | bool | true | Prevents input from being read at the input, textarea, and other editable areas. ## Dev diff --git a/src/index.js b/src/index.js index 826f3d5..bc739c8 100644 --- a/src/index.js +++ b/src/index.js @@ -97,12 +97,12 @@ class BarcodeScanner extends React.Component { handleKeyPress = (e) => { const { - onKeyDetect, onReceive, scanButtonKeyCode, stopPropagation, preventDefault, endChar, startChar, timeBeforeScanTest, + onKeyDetect, onReceive, scanButtonKeyCode, stopPropagation, preventDefault, endChar, startChar, timeBeforeScanTest, preventScanOnInput } = this.props const { target } = e - if (target instanceof window.HTMLElement && isInput(target)) { + if (preventScanOnInput && target instanceof window.HTMLElement && isInput(target)) { return } @@ -173,6 +173,7 @@ BarcodeScanner.propTypes = { stopPropagation: PropTypes.bool, // Stop immediate propagation on keypress event preventDefault: PropTypes.bool, // Prevent default action on keypress event testCode: PropTypes.string, // Test string for simulating + preventScanOnInput: PropTypes.bool, // Prevents input from being read at the input, text area, and other editable areas. } BarcodeScanner.defaultProps = { @@ -184,6 +185,7 @@ BarcodeScanner.defaultProps = { scanButtonLongPressThreshold: 3, stopPropagation: false, preventDefault: false, + preventScanOnInput: true, } export default BarcodeScanner \ No newline at end of file