In my C# application, I handle CTRL and SHIFT in OnKeyDown
as shown below. It works as intented. However, when I press the middle button on my Logitech M705 I get a sequence of unwanted key events. Both foo()
and bar()
get called, which clearly is unwanted behavior. (I suppose the driver generates several key presses to activate some special zoom tool?)
Q: How can I detect these simulated key presses? Or, how can I prevent OnKeyDown
from being called in this particular case?
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.ShiftKey)
foo();
else if (e.KeyCode == Keys.ControlKey)
bar();
}
Sounds to me like your logitec driver has a certain key combination macro bound to your middle button click. Since the driver intentionally simulates keyboard input, I'm not sure it's possible to filter out "fake" keypresses.