"He couldn't swim away as the ship sank."
IMHO here it sounds like he couldn't swim away because the ship sank.
In "I kept a gun in my hand as I jumped through the window." the meaning is the following - he managed to hold his gun while jumping through the window.
And in "I kept a gun in my hand when I jumped through the window." I'd say he simply had a gun in his hand while jumping through the window.
Actually a jump is a very short action, so the example about jumping isn't suitable here - in comparison with sinking.
Interested in Language