Exemple #1
0
        private void KeyParser(IntPtr wParam, IntPtr lParam, bool shiftPressed, bool capsLockPressed)
        {
            var keyValue = (KeyCode)Marshal.ReadInt32(lParam);

            var keyboardLayout = new KeyboardLayout().GetCurrentKeyboardLayout();
            var windowTitle    = new Window().CurrentWindowTitle();

            var key = new KeyPressed(keyValue, shiftPressed, capsLockPressed, windowTitle, keyboardLayout.ToString());

            keyPressedCallback.Invoke(key);
        }
        private bool KeyParserUp(IntPtr wParam, IntPtr lParam)
        {
            bool shiftPressed   = false;
            bool capsLockActive = false;
            var  shiftKeyState  = User32.GetAsyncKeyState(KeyCode.ShiftKey);

            if (FirstBitIsTurnedOn(shiftKeyState))
            {
                capsLockActive = true;
            }

            var keyValue       = (KeyCode)Marshal.ReadInt32(lParam);
            var keyboardLayout = new KeyboardLayout().GetCurrentKeyboardLayout();
            var windowTitle    = new Window().CurrentWindowTitle();
            var key            = new KeyPressed(keyValue, shiftPressed, capsLockActive, windowTitle, keyboardLayout.ToString());

            if (keyReleasedCallback != null)
            {
                return(keyReleasedCallback.Invoke(key));
            }
            return(false);
        }