It would help if you can post more speecifically what you are looking for. It's possible that the input method above may not be what you need. The reason is that it pauses the program waiting for a key press. Although depending on your situation this may be all that you need.
Although it's slightly more complex, it would be more flexible to have a routine that checks for input in a game loop. Stores the keys in an input buffer(as to not miss any keys) and displays them. This way other things can be processed and the program doesn't stop for every key press. Say for example, you want to later use the code in a game. Other events may need to happen while waiting for key presses.
Let us know, and if this is what you need we can provide some snippets for you.