Try using the keypad with one finger pointed, instead of an open hand.
If you look closely at the phone, on the screen side there are two dots to the right of the Samsung logo. Those are the proximity sensor. If any part of your hand gets too close to those while you are using the keypad, it will think your face is close by.
My partner was using an open hand to push the keypad buttons; her middle and ring finger would sometimes get close to the proximity sensor and shut off the screen. Using a pointed finger solves this problem.