gmamaladze / globalmousekeyhook

This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background.
MIT License
1.05k stars 257 forks source link

If I hook a key event, can I prevent it goes to next event handler? #137

Open todatamining opened 3 years ago

todatamining commented 3 years ago

globalmousekeyhook is a nice API.

I am wondering if it is possible to eat an key event. For example, I hook the keydown event and capture "LControlKey".

        m_Events.KeyDown += OnKeyDown;

        private void OnKeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.LControlKey)
             {
                    //do something
             }
       }

After Left Control is handled by function OnKeyDown, I want to drop this key event, so it won't be handled by the system.
Is it possible?

PromoFaux commented 3 years ago

I think you just make the last thing you do e.Handled = true

pedjas commented 1 year ago

I think you just make the last thing you do e.Handled = true

It seems that does not work.