Skip to content

Instantly share code, notes, and snippets.

@Mondonno
Last active February 3, 2022 11:08
Show Gist options
  • Save Mondonno/6aa28ad9080e608c8033f7131f3df26c to your computer and use it in GitHub Desktop.
Save Mondonno/6aa28ad9080e608c8033f7131f3df26c to your computer and use it in GitHub Desktop.
C# Xamarin.IOS/Xamarin.Mac/MAUI keycodes.
public class KeyCodes {
// Layout-independent Keys
// eg.These key codes are always the same key on all layouts.
public const ushort ReturnKey = 0x24;
public const ushort Enter = 0x4C;
public const ushort Tab = 0x30;
public const ushort Space = 0x31;
public const ushort Delete = 0x33;
public const ushort Escape = 0x35;
public const ushort Command = 0x37;
public const ushort Shift = 0x38;
public const ushort CapsLock = 0x39;
public const ushort Option = 0x3A;
public const ushort Control = 0x3B;
public const ushort RightShift = 0x3C;
public const ushort RightOption = 0x3D;
public const ushort RightControl = 0x3E;
public const ushort LeftArrow = 0x7B;
public const ushort RightArrow = 0x7C;
public const ushort DownArrow = 0x7D;
public const ushort UpArrow = 0x7E;
public const ushort VolumeUp = 0x48;
public const ushort VolumeDown = 0x49;
public const ushort Mute = 0x4A;
public const ushort Help = 0x72;
public const ushort Home = 0x73;
public const ushort PageUp = 0x74;
public const ushort ForwardDelete = 0x75;
public const ushort End = 0x77;
public const ushort PageDown = 0x79;
public const ushort Function = 0x3F;
public const ushort F1 = 0x7A;
public const ushort F2 = 0x78;
public const ushort F4 = 0x76;
public const ushort F5 = 0x60;
public const ushort F6 = 0x61;
public const ushort F7 = 0x62;
public const ushort F3 = 0x63;
public const ushort F8 = 0x64;
public const ushort F9 = 0x65;
public const ushort F10 = 0x6D;
public const ushort F11 = 0x67;
public const ushort F12 = 0x6F;
public const ushort F13 = 0x69;
public const ushort F14 = 0x6B;
public const ushort F15 = 0x71;
public const ushort F16 = 0x6A;
public const ushort F17 = 0x40;
public const ushort F18 = 0x4F;
public const ushort F19 = 0x50;
public const ushort F20 = 0x5A;
// US-ANSI Keyboard Positions
// eg. These key codes are for the physical key (in any keyboard layout)
// at the location of the named key in the US-ANSI layout.
public const ushort A = 0x00;
public const ushort B = 0x0B;
public const ushort C = 0x08;
public const ushort D = 0x02;
public const ushort E = 0x0E;
public const ushort F = 0x03;
public const ushort G = 0x05;
public const ushort H = 0x04;
public const ushort I = 0x22;
public const ushort J = 0x26;
public const ushort K = 0x28;
public const ushort L = 0x25;
public const ushort M = 0x2E;
public const ushort N = 0x2D;
public const ushort O = 0x1F;
public const ushort P = 0x23;
public const ushort Q = 0x0C;
public const ushort R = 0x0F;
public const ushort S = 0x01;
public const ushort T = 0x11;
public const ushort U = 0x20;
public const ushort V = 0x09;
public const ushort W = 0x0D;
public const ushort X = 0x07;
public const ushort Y = 0x10;
public const ushort Z = 0x06;
public const ushort Zero = 0x1D;
public const ushort One = 0x12;
public const ushort Two = 0x13;
public const ushort Three = 0x14;
public const ushort Four = 0x15;
public const ushort Five = 0x17;
public const ushort Six = 0x16;
public const ushort Seven = 0x1A;
public const ushort Eight = 0x1C;
public const ushort Nine = 0x19;
public const ushort Equals = 0x18;
public const ushort Minus = 0x1B;
public const ushort Semicolon = 0x29;
public const ushort Apostrophe = 0x27;
public const ushort Comma = 0x2B;
public const ushort Period = 0x2F;
public const ushort ForwardSlash = 0x2C;
public const ushort Backslash = 0x2A;
public const ushort Grave = 0x32;
public const ushort LeftBracket = 0x21;
public const ushort RightBracket = 0x1E;
public const ushort KeypadDecimal = 0x41;
public const ushort KeypadMultiply = 0x43;
public const ushort KeypadPlus = 0x45;
public const ushort KeypadClear = 0x47;
public const ushort KeypadDivide = 0x4B;
public const ushort KeypadEnter = 0x4C;
public const ushort KeypadMinus = 0x4E;
public const ushort KeypadEquals = 0x51;
public const ushort Keypad0 = 0x52;
public const ushort Keypad1 = 0x53;
public const ushort Keypad2 = 0x54;
public const ushort Keypad3 = 0x55;
public const ushort Keypad4 = 0x56;
public const ushort Keypad5 = 0x57;
public const ushort Keypad6 = 0x58;
public const ushort Keypad7 = 0x59;
public const ushort Keypad8 = 0x5B;
public const ushort Keypad9 = 0x5C;
}
@Mondonno
Copy link
Author

Mondonno commented Jan 1, 2022

Credits Hint
The code was re-maked from this gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment