How to use a function for every C# WinForm instead of pasting 
<pre><code>protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            {
                if (keyData == Keys.Escape) this.Close();
                return base.ProcessCmdKey(ref msg, keyData);
            }
        }
</code></pre>

<p>I discovered this snippet to close windows form by esc. I really want to implement this to every windows form. I try to create a new abstract class which inherit from Form and another windows form will inherit from this one . But it doesn't work this way .</p>

<pre><code>abstract class AbsForm: Form {
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            {
                if (keyData == Keys.Escape) this.Close();
                return base.ProcessCmdKey(ref msg, keyData);
            }
        }
    }
    public partial class HoaDonBanSach : AbsForm
    {
        public HoaDonBanSach()
        {
            InitializeComponent();
        }
</code></pre>

<p>Thanks for reading this :)</p>
