Detecting Ctrl + arrow keys
-
I need to distinguish Ctrl and Ctrl+arrow key commands in my app. Using
ProcessCmdMsg
rather thanOnKeyDown
handler allows me to register arrow keys, but when user strikes and holds Ctrl key, there are lot of messages with key code equal to this Control key, bud I'm not able to detect both Ctrl as modifier key and arrow key at the same time. -
I need to distinguish Ctrl and Ctrl+arrow key commands in my app. Using
ProcessCmdMsg
rather thanOnKeyDown
handler allows me to register arrow keys, but when user strikes and holds Ctrl key, there are lot of messages with key code equal to this Control key, bud I'm not able to detect both Ctrl as modifier key and arrow key at the same time.You can please try the below:
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if ( e.Control && e.KeyCode == Keys.Up )
{
this.Text = "Control key + Up Key pressed";
}
else
{
this.Text = "Other Key pressed";
}
}