OnKeyDown: Handled = true is not working when the key is held down

Apr 25, 2014 at 9:14 PM
Edited Apr 25, 2014 at 9:50 PM
I am writing a PowerPoint VSTO plugin which uses both mouse- and keyboard hooks.

I am currently trying to suppress certain keyboard combinations. This works if they are typed or pressed slowly, but if some keys are held in for a long period (> 1 sec or something) the key presses are suddenly sent through to the PowerPoint application.

The current code I'm using is the following:
class KeyEvent
        public KeyEvent()
            // Initialize the global key hook
            KeyboardHookListener keyboardHookManager = new KeyboardHookListener(new AppHooker());
            keyboardHookManager.Enabled = true;

            // Listen to the key event
            keyboardHookManager.KeyDown += KeyboardHookManager_OnKeyDown;

        private void KeyboardHookManager_OnKeyDown(object sender, KeyEventArgs e)
            //Debug.Print("KeyDown \t\t {0}\n", e.KeyCode);
            e.Handled = true;
If I hold for instance the 's' key down, nothing is sent to PowerPoint for about a second, before suddenly multiple 's' key-strokes are sent through until I release the key again.

I have tried to use OnKeyPress instead of OnKeyDown with no luck. I have tried to use the GlobalHooker, rather than the AppHooker, but then the key down event is not raised for any keys when my PowerPoint window is active - so that obviously does not work either.

Are there any suggestions to why suppressing key strokes stops working if the keys are held down for a long period of time? Have I misunderstood how this event works?

I have tried this both with the stable V3 version and the V4 alpha 2 version. Both versions are having the same issue.
Apr 25, 2014 at 9:47 PM
I have also tried to use e.SuppressKeyPress = true in KeyDown event handler without success. After the repeat key stroke time delay kicks in the key is sent through to Windows / PowerPoint...