How to catch CTRL +C key press

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,

What is the best way to catch the user prressig the CTRL- C key combination..
I have try the keypress ans key down event but I am able only to catch one
key at a time ..

Amy idea ?

regard
serge
 
In a WinForms app override the ProcessCmdKey:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (msg.Msg)
{
case 0x100:
case 0x104:
switch (keyData)
{
case Keys.Control | Keys.C:
MessageBox.Show("Ctrl + C pressed");
break;
}
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}

Gabriel Lozano-Morán
http://www.pointerx.net
 
Hi Serge,

Actually, it can be done using the KeyDown event:

private void ctrl_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.C)
{
// TODO: Ctrl+C pressed in control
}
}
 
Back
Top