I want to execute a statement when a particular key is pressed. How do I do it?

Thank you,
Sean.