472,119 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

How to catch CTRL +C key press

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
Nov 25 '06 #1
2 20940
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

"calderara" <ca*******@discussions.microsoft.comwrote in message
news:BA**********************************@microsof t.com...
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
Nov 26 '06 #2
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
}
}

--
Dave Sexton

"calderara" <ca*******@discussions.microsoft.comwrote in message
news:BA**********************************@microsof t.com...
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

Nov 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Alex Ostrikov | last post: by
3 posts views Thread by Greg | last post: by
6 posts views Thread by Paul Gorodyansky | last post: by
1 post views Thread by Claudiu Felecan | last post: by
3 posts views Thread by Glen Hong | last post: by
1 post views Thread by Jinsong | last post: by
1 post views Thread by iwdu15 | last post: by
5 posts views Thread by Samik R. | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.