#nullable enable namespace Terminal.Gui; /// /// The enumeration encodes key information from s and provides a /// consistent way for application code to specify keys and receive key events. /// /// The class provides a higher-level abstraction, with helper methods and properties for /// common operations. For example, and provide a convenient way /// to check whether the Alt or Ctrl modifier keys were pressed when a key was pressed. /// /// /// /// /// Lowercase alpha keys are encoded as values between 65 and 90 corresponding to the un-shifted A to Z keys on a /// keyboard. Enum values are provided for these (e.g. , , etc.). /// Even though the values are the same as the ASCII values for uppercase characters, these enum values represent /// *lowercase*, un-shifted characters. /// /// /// Numeric keys are the values between 48 and 57 corresponding to 0 to 9 (e.g. , /// , etc.). /// /// /// The shift modifiers (, , and /// ) can be combined (with logical or) with the other key codes to represent shifted /// keys. For example, the enum value represents the un-shifted 'a' key, while /// | represents the 'A' key (shifted 'a' key). Likewise, /// | represents the 'Alt+A' key combination. /// /// /// All other keys that produce a printable character are encoded as the Unicode value of the character. For /// example, the for the '!' character is 33, which is the Unicode value for '!'. Likewise, /// `â` is 226, `Â` is 194, etc. /// /// /// If the is set, then the value is that of the special mask, otherwise, the value is /// the one of the lower bits (as extracted by ). /// /// [Flags] public enum KeyCode : uint { /// /// Mask that indicates that the key is a unicode codepoint. Values outside this range indicate the key has shift /// modifiers or is a special key like function keys, arrows keys and so on. /// CharMask = 0x_f_ffff, /// /// If the is set, then the value is that of the special mask, otherwise, the value is /// in the lower bits (as extracted by ). /// SpecialMask = 0x_fff0_0000, /// /// When this value is set, the Key encodes the sequence Shift-KeyValue. The actual value must be extracted by /// removing the ShiftMask. /// ShiftMask = 0x_1000_0000, /// /// When this value is set, the Key encodes the sequence Alt-KeyValue. The actual value must be extracted by /// removing the AltMask. /// AltMask = 0x_8000_0000, /// /// When this value is set, the Key encodes the sequence Ctrl-KeyValue. The actual value must be extracted by /// removing the CtrlMask. /// CtrlMask = 0x_4000_0000, /// The key code representing an invalid or empty key. Null = 0, /// Backspace key. Backspace = 8, /// The key code for the tab key (forwards tab key). Tab = 9, /// The key code for the return key. Enter = ConsoleKey.Enter, /// The key code for the clear key. Clear = 12, /// The key code for the escape key. Esc = 27, /// The key code for the space bar key. Space = 32, /// Digit 0. D0 = 48, /// Digit 1. D1, /// Digit 2. D2, /// Digit 3. D3, /// Digit 4. D4, /// Digit 5. D5, /// Digit 6. D6, /// Digit 7. D7, /// Digit 8. D8, /// Digit 9. D9, /// The key code for the A key A = 65, /// The key code for the B key B, /// The key code for the C key C, /// The key code for the D key D, /// The key code for the E key E, /// The key code for the F key F, /// The key code for the G key G, /// The key code for the H key H, /// The key code for the I key I, /// The key code for the J key J, /// The key code for the K key K, /// The key code for the L key L, /// The key code for the M key M, /// The key code for the N key N, /// The key code for the O key O, /// The key code for the P key P, /// The key code for the Q key Q, /// The key code for the R key R, /// The key code for the S key S, /// The key code for the T key T, /// The key code for the U key U, /// The key code for the V key V, /// The key code for the W key W, /// The key code for the X key X, /// The key code for the Y key Y, /// The key code for the Z key Z, ///// ///// The key code for the Delete key. ///// //Delete = 127, // --- Special keys --- // The values below are common non-alphanum keys. Their values are // based on the .NET ConsoleKey values, which, in-turn are based on the // VK_ values from the Windows API. // We add MaxCodePoint to avoid conflicts with the Unicode values. /// The maximum Unicode codepoint value. Used to encode the non-alphanumeric control keys. MaxCodePoint = 0x10FFFF, /// Cursor up key CursorUp = MaxCodePoint + ConsoleKey.UpArrow, /// Cursor down key. CursorDown = MaxCodePoint + ConsoleKey.DownArrow, /// Cursor left key. CursorLeft = MaxCodePoint + ConsoleKey.LeftArrow, /// Cursor right key. CursorRight = MaxCodePoint + ConsoleKey.RightArrow, /// Page Up key. PageUp = MaxCodePoint + ConsoleKey.PageUp, /// Page Down key. PageDown = MaxCodePoint + ConsoleKey.PageDown, /// Home key. Home = MaxCodePoint + ConsoleKey.Home, /// End key. End = MaxCodePoint + ConsoleKey.End, /// Insert (INS) key. Insert = MaxCodePoint + ConsoleKey.Insert, /// Delete (DEL) key. Delete = MaxCodePoint + ConsoleKey.Delete, /// Print screen character key. PrintScreen = MaxCodePoint + ConsoleKey.PrintScreen, /// F1 key. F1 = MaxCodePoint + ConsoleKey.F1, /// F2 key. F2 = MaxCodePoint + ConsoleKey.F2, /// F3 key. F3 = MaxCodePoint + ConsoleKey.F3, /// F4 key. F4 = MaxCodePoint + ConsoleKey.F4, /// F5 key. F5 = MaxCodePoint + ConsoleKey.F5, /// F6 key. F6 = MaxCodePoint + ConsoleKey.F6, /// F7 key. F7 = MaxCodePoint + ConsoleKey.F7, /// F8 key. F8 = MaxCodePoint + ConsoleKey.F8, /// F9 key. F9 = MaxCodePoint + ConsoleKey.F9, /// F10 key. F10 = MaxCodePoint + ConsoleKey.F10, /// F11 key. F11 = MaxCodePoint + ConsoleKey.F11, /// F12 key. F12 = MaxCodePoint + ConsoleKey.F12, /// F13 key. F13 = MaxCodePoint + ConsoleKey.F13, /// F14 key. F14 = MaxCodePoint + ConsoleKey.F14, /// F15 key. F15 = MaxCodePoint + ConsoleKey.F15, /// F16 key. F16 = MaxCodePoint + ConsoleKey.F16, /// F17 key. F17 = MaxCodePoint + ConsoleKey.F17, /// F18 key. F18 = MaxCodePoint + ConsoleKey.F18, /// F19 key. F19 = MaxCodePoint + ConsoleKey.F19, /// F20 key. F20 = MaxCodePoint + ConsoleKey.F20, /// F21 key. F21 = MaxCodePoint + ConsoleKey.F21, /// F22 key. F22 = MaxCodePoint + ConsoleKey.F22, /// F23 key. F23 = MaxCodePoint + ConsoleKey.F23, /// F24 key. F24 = MaxCodePoint + ConsoleKey.F24 }