Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test for 'Ctrl' keydown in C#

Tags:

c#

winforms

How do I test for Ctrl down in Windows Forms/C#?

like image 531
SuperSuperDev1234 Avatar asked Jul 17 '09 14:07

SuperSuperDev1234


People also ask

What is the difference between keypress and KeyDown?

The keydown and keyup events provide a code indicating which key is pressed, while keypress indicates which character was entered. For example, a lowercase "a" will be reported as 65 by keydown and keyup , but as 97 by keypress .

What is KeyDown event in C#?

KeyDown Event : This event raised as soon as the user presses a key on the keyboard, it repeats while the user keeps the key depressed. KeyUp Event : This event is raised after the user releases a key on the keyboard.

What is KeyCode C#?

C# This page was last reviewed on Sep 25, 2022. KeyCode handles key presses. You have a TextBox control on your Windows Forms application and need to detect Enter. With KeyCode, we can detect keys.


1 Answers

bool ctrl = ((Control.ModifierKeys & Keys.Control) == Keys.Control);
like image 127
Marc Gravell Avatar answered Sep 30 '22 01:09

Marc Gravell