Vixen
02b45cc4
csharp
public enum Key

A key by its physical position, independent of the keyboard layout.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

There is deliberately no second, layout-dependent enum. The names below are the US-QWERTY legends because something has to name a position, but the value identifies the key's place on the keyboard, not the character it produces: on a French AZERTY layout Q is the key labelled A, and on Dvorak W is where , is printed.

That is the right primitive for the two things games do with a keyboard. A binding — WASD movement — wants the physical position, so the shape under the player's left hand is the same on every layout, which is why every engine that shipped a layout-dependent binding system eventually rewrote it. Typing wants the character, and a character is not a key: it may need a dead key, an IME, or several keystrokes to produce. So typed text arrives as TextInput carrying a string, and never as a key code the caller is expected to translate.

The values follow the USB HID usage table for keyboards, which is what SDL, the browser (KeyboardEvent.code) and Windows scancodes all ultimately derive from, so a backend translates by table lookup rather than by a hundred-case switch.

Fields and properties (119)

  • Unknown

    No key, or a key this platform does not report.

  • A
  • B
  • C
  • D
  • E
  • F
  • G
  • H
  • I
  • J
  • K
  • L
  • M
  • N
  • O
  • P
  • Q
  • R
  • S
  • T
  • U
  • V
  • W
  • X
  • Y
  • Z
  • Number1

    The 1 on the number row, not the numeric keypad.

  • Number2
  • Number3
  • Number4
  • Number5
  • Number6
  • Number7
  • Number8
  • Number9
  • Number0
  • Enter
  • Escape
  • Backspace
  • Tab
  • Space
  • Minus
  • Equals
  • LeftBracket
  • RightBracket
  • Backslash
  • Semicolon
  • Apostrophe
  • Grave
  • Comma
  • Period
  • Slash
  • CapsLock
  • F1
  • F2
  • F3
  • F4
  • F5
  • F6
  • F7
  • F8
  • F9
  • F10
  • F11
  • F12
  • PrintScreen
  • ScrollLock
  • Pause
  • Insert
  • Home
  • PageUp
  • Delete
  • End
  • PageDown
  • Right
  • Left
  • Down
  • Up
  • NumLock
  • KeypadDivide
  • KeypadMultiply
  • KeypadMinus
  • KeypadPlus
  • KeypadEnter
  • Keypad1
  • Keypad2
  • Keypad3
  • Keypad4
  • Keypad5
  • Keypad6
  • Keypad7
  • Keypad8
  • Keypad9
  • Keypad0
  • KeypadPeriod
  • NonUsBackslash

    The extra key next to left shift on ISO keyboards, absent on ANSI ones.

  • Application

    The menu key, and the same physical key Android reports for its menu button.

  • F13
  • F14
  • F15
  • F16
  • F17
  • F18
  • F19
  • F20
  • F21
  • F22
  • F23
  • F24
  • LeftControl
  • LeftShift
  • LeftAlt

    Left Alt, and Option on a Mac.

  • LeftMeta

    Left Windows, Command on a Mac, Super on Linux.

  • RightControl
  • RightShift
  • RightAlt

    Right Alt, which is AltGr on layouts that have one.

  • RightMeta

    Right Windows, Command on a Mac, Super on Linux.

  • Back

    Android's hardware back button, and the browser's back gesture.

Used by (13)

  • DesktopInputSourceVixen.Platform.Desktop
  • HeadlessInputSourceVixen.Platform.Headless
  • HeadlessLifecycleTestsVixen.Platform.Headless.Tests
  • HeadlessPlatformTestsVixen.Platform.Headless.Tests
  • IInputSourceVixen.Platform
  • InputKeyTestsVixen.Input.Tests
  • PlatformEventVixen.Platform
  • PlatformEventBufferTestsVixen.Platform.Tests
  • PlatformEventTestsVixen.Platform.Tests
  • SdlTranslationVixen.Platform.Desktop
  • SdlTranslationTestsVixen.Platform.Desktop.Tests
  • PlatformInputTestsVixen.App.Tests
  • VixenApplicationTestsVixen.App.Tests