First time here? Check out the FAQ!
answered 2016-03-20 15:03:22 -0600
See the documentation of waitKey to see how to wait for the key to be pressed.
See imwrite for how to save an image.
And HERE is a tutorial that does part of what you want.