I've had this problem today, so I thought I need to post my solution in case anyone else finds this useful.
I use Numpad keyboard to play Touhou, and in Subterranean Animism keys were locking randomly and my player character would fly into a random direction and she couldn't be stopped. Apparently, this happens when Numlock key is active, so disabling the Numlock key fixes this specific problem.