Yep, using the barcode scanner sdk would be the best solution.
If want to avoid to code that OEM specific stuff you may workaround your issue using the keyboard wedges pos- and/or pre-amble settings.
Most if not all of the wedge implementations support adding a sequence before and after the scanned data, this may be called preamble and postanble. Using this feature you can change your code and for example disregard and keypresses if they start with * and end with # for example. If so, just add * as preamble and # as postamble in the wedge setup of your device. Using this technique you have to remove the chars in your barcode input field before you go on and validate/process the barcode data.