Example #1
0
        // https://stackoverflow.com/a/1916241/7003797
        private void OnKeyPressed(Keys key, int position, int documentId)
        {
            if (KeyPressed != null)
            {
                var eventListeners = KeyPressed.GetInvocationList();

                for (int index = 0; index < eventListeners.Length; index++)
                {
                    var methodToInvoke = (EventHandler <KeyboardHookEventArgs>)eventListeners[index];

                    methodToInvoke.BeginInvoke(
                        this,
                        new KeyboardHookEventArgs(key, position, documentId),
                        EndOnKeyPressed,
                        null
                        );
                }
            }
        }