Live Chat Icon For mobile
Live Chat Icon

How do I make the arrow keys be accepted by a control (such as a button) and not handled automatically by the framework’s focus management

Platform: WinForms| Category: Controls

By default, the arrow keys are not handled by a control’s key processing code, but instead are filtered out for focus management. Hence, the control’s KeyDown, KeyUp and KeyPressed events are not hit when you press an arrow. If you want your control to handle these keyboard events, you tell the framework by overriding your control’s IsInputKey method.

   protected override bool IsInputKey(Keys key) 
        		case Keys.Up:
        		case Keys.Down:
        		case Keys.Right:
        		case Keys.Left:
            		return true;
    	return base.IsInputKey(key);

Share with

Related FAQs

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

Please submit your question and answer.