What can I guess from your problem, the user stops scanning when he hears the error sound. If so, why wait until the user stops scanning.
You can do any of the following:
As soon as an error occurs, stop entering data. you can set 'keypress' to return false. You can also set a buffer on a keypress event, which first stores the input and then returns false. Thus, you will receive data after an error occurs.
source share