Perhaps you’re doing more than you should when you press a key. If there’s no flicker while you’re not pressing a key (assuming your animation continues running with no keys being pressed), then that might be it.
Otherwise, it could be that you are no syncing your refresh with the VBL update.
flash grey… that seem like the erasebkgnd message of the window isnt intecepted and that clears the window with the standard button color ( in windows its often grey)