add flushing of stdout to update on key event

Doing this as a demo for UC Berkeley Practical Neuroimaging class on
contributing to open source while getting your work done. This demo only printed the previous key *after* you pressed another key. 

With these changes, we print the key that was last pressed immediately after the event