Home > Net >  Consult, form single CTRL key trigger how to implement
Consult, form single CTRL key trigger how to implement

Time:10-03

Teach,
A winform form, when the cursor in any position, press the left CTRL key alone call a method;
But CTRL + c and CTRL + v when not triggered

CodePudding user response:

Press and hold down and trigger buttons? The three listening event is not the same, if it is pressed or hold down the trigger you may want to through the Windows API interceptor window message to do it, if it is a key process after the completion of the (press - & gt; Press and hold - & gt; Loosen the whole process is completed) should be able to intercept keypress events by e.k eycode judgment,
For a long time didn't do it form the interception of these events, maybe all I said was wrong also maybe,

CodePudding user response:

Add a key event to form
Determines if press the Ctrl key

CodePudding user response:

KeyUp event registration form, that is, after the button press release trigger events
Within the event write statement:
If (e.K ey==Key. LeftCtrl | | e.K ey==Key. RightCtrl)

CodePudding user response:

The
refer to the original poster fayerch response:
to teach,
A winform form, when the cursor in any position, press the left CTRL key alone call a method;
But CTRL + c and CTRL + v without triggering

I looked at your demand, please carefully recall you press Ctrl + c and Ctrl + v how buttons, is hold down Ctrl and then press the c or v, so, when you are in the single coordinate Ctrl is triggered when the event and then press the c exactly how to judge? So you want to be clear, you this single press, press is, hold or press down to loosen the entire process,

CodePudding user response:

CTRL c CTRL v is system command
Do you want to override form ProcessCmdKey to see

CodePudding user response:

 protected override bool ProcessCmdKey (ref Message MSG, Keys keyData) 
{
If (keyData=https://bbs.csdn.net/topics/=(Keys. Control | Keys. C))
{
//your code
return true;
}
The else
Return to base. ProcessCmdKey (ref MSG, keyData);
}

CodePudding user response:

Left, like a bad, need to take time to write you one
  •  Tags:  
  • C#