I've been bitten by this too, and it's happened to me in more than one direction, meaning: continually going forward or looking through the periscope going round and round and round until I get all dizzy...
I've been able to solve either by hitting control and arrow keys randomly, which sometimes seems to stop it. Or going to an unavailable station on the boat. Say, I am using the external cam while submerged and I get stuck keys, I punch up the conn using F4, which can't be done while submerged, of course. This seems to hold the motion for some reason. It happens quite often while using the shift or control keys in combination with the arrow keys. I also find it happens more often if there's heavy traffic nearby.