Thats an easy question to anwser.
These handheld QR/Bar code scanners are designed to be save in every circumstance.
Class 2 actually defines this very well.
Its classified to be safe for looking into it for short periods of time, with the addition of "dont stare into beam". So your described exposure to it is completely safe.
However your question if a different laser could be unsafe even if only peripheral: clearly yes, but it depends. If your laser is powerful enough, even a hit to the skin could be dangerous. Every laser of class >2 is considered dangerous for even short exposures.
The general principal for eye damage is that the laser "burns" (do to heat) a spot on your retina, so if the power is high enough and the duration is long enough, it will damage the retina. So even side radiation will/could burn your retina, however is quite unlikely. As the angle gets more shallow, the pupil will let less and less light inside your eye, meaning lower power thus lower likelihood of burning.
These Barcode scanner are designed to be save. They have class 2 because you could in theory hold the scanner directly to your eyeball and try to capture all the light thats emitted. This would result in the biggest energy captured on your retina, thus creating enough heat to burn your retina. So the manufacturer will use class 2. Because the beam is quite divergent (meaning it expands fast), the cross thats projected will be much bigger at a distance, spreading the power to a much bigger area. This means if you are any significant distance away from the source (even 5"), the power is very low because not all energy is captured by your pupil. This explains why they need to specify "dont stare into it" but it also explains why ist safe in your situation.
Unown it right (but could have reacted way better), if you have any problems, go see a doctor, we are no specialists, however class 2 is a dead give away thats safe unless you are really reckless with it. (Trying to capture the whole beam with your eye at a short distance essentially pressing your eyeball against the output window)