Mosa.DeviceSystem.Keyboard.GetKeyPressed C# (CSharp) Method

GetKeyPressed() public method

Gets the key pressed.
public GetKeyPressed ( ) : Key
return Key
        public Key GetKeyPressed()
        {
            byte scanCode = keyboardDevice.GetScanCode();

            if (scanCode == 0)
                return null;

            var keyEvent = scanCodeMap.ConvertScanCode(scanCode);

            if (keyEvent.KeyType == KeyType.RegularKey)
            {
                if (keyEvent.KeyPress == KeyEvent.KeyPressType.Make)
                {
                    var key = new Key();
                    key.KeyType = keyEvent.KeyType;
                    key.Character = keyEvent.Character;
                    key.Alt = Alt;
                    key.Control = Control;
                    key.Shift = Shift;
                    return key;
                }
            }

            if (keyEvent.KeyType == KeyType.CapsLock)
                CapLock = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);
            else if (keyEvent.KeyType == KeyType.NumLock)
                NumLock = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);
            else if (keyEvent.KeyType == KeyType.ScrollLock)
                ScrollLock = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);
            else if (keyEvent.KeyType == KeyType.LeftControl)
                LeftControl = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);
            else if (keyEvent.KeyType == KeyType.RightControl)
                RightControl = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);
            else if (keyEvent.KeyType == KeyType.LeftAlt)
                LeftAlt = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);
            else if (keyEvent.KeyType == KeyType.RightAlt)
                RightAlt = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);
            else if (keyEvent.KeyType == KeyType.LeftShift)
                LeftShift = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);
            else if (keyEvent.KeyType == KeyType.RightShift)
                RightShift = (keyEvent.KeyPress == KeyEvent.KeyPressType.Make);

            return null;
        }