'Disable some letter keys in MaskedTextBox

I want a MaskedTextBox that is made for hex color codes, such as "#73E57E" for example. This means that only 0-9 and A-F shall be allowed. My mask is ">AAAAAA". What I can't figure out is how do disable some letters. So that when I hit the "G" key, nothing shall happen. Exectly as if I hit the "+" key for example.

This is what I have tested so far:

        private void mskBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.G)
            {
                e.Handled = true;
            }
        }
        private void mskBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.H)
            {
                e.Handled = true;
            }
        }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source