The code above its only for test purposes using that keys for input changing the ball_speed vector (x,y,z axis movement). If you are constantly pressing the keys the ball cant bounce because there is always a force applied on it against the wall. I didnt test but if you apply a force to the ball like ball_speed.x = 50, ball_speed.y = 80, ball_speed.z = 0 for example:

function apply_force()
{
ball_speed.x = 50;
ball_speed.y = 80;
ball_speed.z = 0;
}

on_z = apply_force;

may it will work. Hope it helps.