Regardless of whether it was deliberate or not, the defender affected the direction of the ball.
For clarity, Rule 12 “Fouls and Misconduct†regarding handball, whether inside the penalty box or outside it as I understand it, is laid out below.
No mention of affecting the direction of the ball
HANDLING THE BALL
Handling the ball involves a deliberate act of a player making contact with the ball with the hand or arm.
The following must be considered:
the movement of the hand towards the ball (not the ball towards the hand)
the distance between the opponent and the ball (unexpected ball)
the position of the hand does not necessarily mean that there is an offence
touching the ball with an object held in the hand (clothing, shinguard, etc.) is an offence
hitting the ball with a thrown object (boot, shinguard, etc.) is an offence
The goalkeeper has the same restrictions on handling the ball as any other player outside the penalty area. Inside their penalty area, the goalkeeper cannot be guilty of a handling offence incurring a direct free kick or any related sanction but can be guilty of handling offences that incur an indirect free kick.