Live Chat Icon For mobile
Live Chat Icon

How can I tell if an ALT, Shift or CTL key is pressed without catching an event

Platform: WinForms| Category: Keyboard Handling

Use the static property Control.ModifierKeys.

	Console.WriteLine(Control.ModifierKeys);
	if( (Control.ModifierKeys & Keys.Shift) != 0)
		Console.WriteLine('the shift key is down');
	if( (Control.ModifierKeys & Keys.Alt) != 0)
		Console.WriteLine('the alt key is down');
	if( (Control.ModifierKeys & Keys.Control) != 0)
		Console.WriteLine('the control key is down');

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.