I simply want to get the character 1...n inside my function when the user presses ctrl +1....n in the form. if i use keypress event for this:
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
MessageBox.Show("KeyPress " + Keys.Shift);
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
MessageBox.Show("KeyPress " + Keys.Control);
}
If I press Shift+1 I see the message "Shift pressed" on the screen. If I press ctrl+1, no message appears on the screen. For example, if I press ctrl+b, I see the "control pressed" message on the screen again this time. so ctrl doesn't work for combinations of numbers.
it can be said, use the keydown method, in that case the event is running as long as I hold down ctrl, which bothers me. I want to know is there a way to solve this with "keypress"?
note: I know how to do this with "keydown" :
if (Char.IsDigit(((char)e.KeyCode)) && e.Modifiers == Keys.Control)
{
MessageBox.Show("KeyDown :" + ((char)e.KeyCode));
}