You can not get pregnant by being in the general vicinity of a guy who is masturbating.
—
This is particularly true if you are wearing underwear. The sperm can not magically fly through the air, sneak under the leg of your panties, and find their way into your vagina. Unlike many popular brands of maxi-pads, they do not have wings. They also do not have access to either small aircraft or a transporter beam.
Explanation for why you can’t get pregnant by being vaguely near a source of semen
In order for you to get pregnant, live sperm have to be able to swim up into your body, make their way up through your vagina, cervix, and uterus, head into your fallopian tubes, find an egg, and fertilize it. However, in order to be able to swim up there, they have to be vagina adjacent. They can’t jet over from across the room, put on tiny scuba gear, and go for a dive.
Therefore, while there is some possibility that you could get pregnant from a guy ejaculating onto your vulva, there is no risk of pregnancy from him ejaculating somewhere else in a room that you happen to share… unless that someplace else is “inside your body.”