This concept always fascinated me. I always wondered how to do it in .NET. Then came the MSDN in rescue. So here I am sharing a tip to do it.
Step 1 : In the windows form there is a property KeyPreview make it to True . By default it is False.
Step 2 : In the KeyDown event of the form write this small code.
if (e.KeyCode == Keys.Escape)this.Dispose();